Commit ce949717b559709423c1ef716a9db16d1dcadaed

Authored by Linus Torvalds

Merge git://github.com/rustyrussell/linux

* git://github.com/rustyrussell/linux:
  lguest: move process freezing before pending signals check
  lguest: don't allow KVM-detection cpuid.
  lguest: Allow running under paravirt-enabled KVM.

Showing 2 changed files Side-by-side Diff

arch/x86/lguest/boot.c
... ... @@ -70,6 +70,7 @@
70 70 #include <asm/i387.h>
71 71 #include <asm/stackprotector.h>
72 72 #include <asm/reboot.h> /* for struct machine_ops */
  73 +#include <asm/kvm_para.h>
73 74  
74 75 /*G:010
75 76 * Welcome to the Guest!
... ... @@ -455,6 +456,15 @@
455 456 *ax &= 0xFFFFF0FF;
456 457 *ax |= 0x00000500;
457 458 break;
  459 +
  460 + /*
  461 + * This is used to detect if we're running under KVM. We might be,
  462 + * but that's a Host matter, not us. So say we're not.
  463 + */
  464 + case KVM_CPUID_SIGNATURE:
  465 + *bx = *cx = *dx = 0;
  466 + break;
  467 +
458 468 /*
459 469 * 0x80000000 returns the highest Extended Function, so we futureproof
460 470 * like we do above by limiting it to known fields.
drivers/lguest/core.c
... ... @@ -232,6 +232,13 @@
232 232 }
233 233 }
234 234  
  235 + /*
  236 + * All long-lived kernel loops need to check with this horrible
  237 + * thing called the freezer. If the Host is trying to suspend,
  238 + * it stops us.
  239 + */
  240 + try_to_freeze();
  241 +
235 242 /* Check for signals */
236 243 if (signal_pending(current))
237 244 return -ERESTARTSYS;
... ... @@ -246,13 +253,6 @@
246 253 try_deliver_interrupt(cpu, irq, more);
247 254  
248 255 /*
249   - * All long-lived kernel loops need to check with this horrible
250   - * thing called the freezer. If the Host is trying to suspend,
251   - * it stops us.
252   - */
253   - try_to_freeze();
254   -
255   - /*
256 256 * Just make absolutely sure the Guest is still alive. One of
257 257 * those hypercalls could have been fatal, for example.
258 258 */
... ... @@ -313,7 +313,7 @@
313 313 int err;
314 314  
315 315 /* Lguest can't run under Xen, VMI or itself. It does Tricky Stuff. */
316   - if (paravirt_enabled()) {
  316 + if (get_kernel_rpl() != 0) {
317 317 printk("lguest is afraid of being a guest\n");
318 318 return -EPERM;
319 319 }