1. 26 2月, 2008 2 次提交
    • A
      x86/lguest: fix pgdir pmd index calculation · 1ce70c4f
      Ahmed S. Darwish 提交于
      Hi all,
      
      Beginning from commits close to v2.6.25-rc2, running lguest always oopses
      the host kernel. Oops is at [1].
      
      Bisection led to the following commit:
      
      commit 37cc8d7f
      
          x86/early_ioremap: don't assume we're using swapper_pg_dir
      
          At the early stages of boot, before the kernel pagetable has been
          fully initialized, a Xen kernel will still be running off the
          Xen-provided pagetables rather than swapper_pg_dir[].  Therefore,
          readback cr3 to determine the base of the pagetable rather than
          assuming swapper_pg_dir[].
      
       static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
       {
      -	pgd_t *pgd = &swapper_pg_dir[pgd_index(addr)];
      +	/* Don't assume we're using swapper_pg_dir at this point */
      +	pgd_t *base = __va(read_cr3());
      +	pgd_t *pgd = &base[pgd_index(addr)];
       	pud_t *pud = pud_offset(pgd, addr);
       	pmd_t *pmd = pmd_offset(pud, addr);
      
      Trying to analyze the problem, it seems on the guest side of lguest,
      %cr3 has a different value from &swapper_pg-dir (which
      is AFAIK fine on a pravirt guest):
      
      Putting some debugging messages in early_ioremap_pmd:
      
      /* Appears 3 times */
      [    0.000000] ***************************
      [    0.000000] __va(%cr3) = c0000000, &swapper_pg_dir = c02cc000
      [    0.000000] ***************************
      
      After 8 hours of debugging and staring on lguest code, I noticed something
      strange in paravirt_ops->set_pmd hypercall invocation:
      
      static void lguest_set_pmd(pmd_t *pmdp, pmd_t pmdval)
      {
      	*pmdp = pmdval;
      	lazy_hcall(LHCALL_SET_PMD, __pa(pmdp)&PAGE_MASK,
      		   (__pa(pmdp)&(PAGE_SIZE-1))/4, 0);
      }
      
      The first hcall parameter is global pgdir which looks fine. The second
      parameter is the pmd index in the pgdir which is suspectful.
      
      AFAIK, calculating the index of pmd does not need a divisoin over four.
      Removing the division made lguest work fine again . Patch is at [2].
      
      I am not sure why the division over four existed in the first place. It
      seems bogus, maybe the Xen patch just made the problem appear ?
      
      [2]: The patch:
      
      [PATCH] lguest: fix pgdir pmd index cacluation
      
      Remove an error in index calculation which leads to removing
      a not existing shadow page table (leading to a Null dereference).
      Signed-off-by: NAhmed S. Darwish <darwish.07@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      1ce70c4f
    • H
      lguest: include function prototypes · cbc34973
      Harvey Harrison 提交于
      Added a declaration to asm-x86/lguest.h and moved the extern arrays there
      as well.  As an alternative to including asm/lguest.h directly, an
      include could be put in linux/lguest.h
      Signed-off-by: NHarvey Harrison <harvey.harrison@gmail.com>
      Cc: "rusty@rustcorp.com.au" <rusty@rustcorp.com.au>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      cbc34973
  2. 30 1月, 2008 7 次提交
  3. 05 11月, 2007 2 次提交
  4. 25 10月, 2007 3 次提交
  5. 24 10月, 2007 1 次提交
  6. 23 10月, 2007 10 次提交
  7. 17 10月, 2007 3 次提交
    • H
      [x86] remove uses of magic macros for boot_params access · 30c82645
      H. Peter Anvin 提交于
      Instead of using magic macros for boot_params access, simply use the
      boot_params structure.
      Signed-off-by: NH. Peter Anvin <hpa@zytor.com>
      30c82645
    • J
      paravirt: clean up lazy mode handling · 8965c1c0
      Jeremy Fitzhardinge 提交于
      Currently, the set_lazy_mode pv_op is overloaded with 5 functions:
       1. enter lazy cpu mode
       2. leave lazy cpu mode
       3. enter lazy mmu mode
       4. leave lazy mmu mode
       5. flush pending batched operations
      
      This complicates each paravirt backend, since it needs to deal with
      all the possible state transitions, handling flushing, etc. In
      particular, flushing is quite distinct from the other 4 functions, and
      seems to just cause complication.
      
      This patch removes the set_lazy_mode operation, and adds "enter" and
      "leave" lazy mode operations on mmu_ops and cpu_ops.  All the logic
      associated with enter and leaving lazy states is now in common code
      (basically BUG_ONs to make sure that no mode is current when entering
      a lazy mode, and make sure that the mode is current when leaving).
      Also, flush is handled in a common way, by simply leaving and
      re-entering the lazy mode.
      
      The result is that the Xen, lguest and VMI lazy mode implementations
      are much simpler.
      Signed-off-by: NJeremy Fitzhardinge <jeremy@xensource.com>
      Cc: Andi Kleen <ak@suse.de>
      Cc: Zach Amsden <zach@vmware.com>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Avi Kivity <avi@qumranet.com>
      Cc: Anthony Liguory <aliguori@us.ibm.com>
      Cc: "Glauber de Oliveira Costa" <glommer@gmail.com>
      Cc: Jun Nakajima <jun.nakajima@intel.com>
      8965c1c0
    • J
      paravirt: refactor struct paravirt_ops into smaller pv_*_ops · 93b1eab3
      Jeremy Fitzhardinge 提交于
      This patch refactors the paravirt_ops structure into groups of
      functionally related ops:
      
      pv_info - random info, rather than function entrypoints
      pv_init_ops - functions used at boot time (some for module_init too)
      pv_misc_ops - lazy mode, which didn't fit well anywhere else
      pv_time_ops - time-related functions
      pv_cpu_ops - various privileged instruction ops
      pv_irq_ops - operations for managing interrupt state
      pv_apic_ops - APIC operations
      pv_mmu_ops - operations for managing pagetables
      
      There are several motivations for this:
      
      1. Some of these ops will be general to all x86, and some will be
         i386/x86-64 specific.  This makes it easier to share common stuff
         while allowing separate implementations where needed.
      
      2. At the moment we must export all of paravirt_ops, but modules only
         need selected parts of it.  This allows us to export on a case by case
         basis (and also choose which export license we want to apply).
      
      3. Functional groupings make things a bit more readable.
      
      Struct paravirt_ops is now only used as a template to generate
      patch-site identifiers, and to extract function pointers for inserting
      into jmp/calls when patching.  It is only instantiated when needed.
      Signed-off-by: NJeremy Fitzhardinge <jeremy@xensource.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Cc: Andi Kleen <ak@suse.de>
      Cc: Zach Amsden <zach@vmware.com>
      Cc: Avi Kivity <avi@qumranet.com>
      Cc: Anthony Liguory <aliguori@us.ibm.com>
      Cc: "Glauber de Oliveira Costa" <glommer@gmail.com>
      Cc: Jun Nakajima <jun.nakajima@intel.com>
      93b1eab3
  8. 13 9月, 2007 1 次提交
  9. 12 8月, 2007 1 次提交
    • A
      i386: Make patching more robust, fix paravirt issue · ab144f5e
      Andi Kleen 提交于
      Commit 19d36ccd "x86: Fix alternatives
      and kprobes to remap write-protected kernel text" uses code which is
      being patched for patching.
      
      In particular, paravirt_ops does patching in two stages: first it
      calls paravirt_ops.patch, then it fills any remaining instructions
      with nop_out().  nop_out calls text_poke() which calls
      lookup_address() which calls pgd_val() (aka paravirt_ops.pgd_val):
      that call site is one of the places we patch.
      
      If we always do patching as one single call to text_poke(), we only
      need make sure we're not patching the memcpy in text_poke itself.
      This means the prototype to paravirt_ops.patch needs to change, to
      marshal the new code into a buffer rather than patching in place as it
      does now.  It also means all patching goes through text_poke(), which
      is known to be safe (apply_alternatives is also changed to make a
      single patch).
      
      AK: fix compilation on x86-64 (bad rusty!)
      AK: fix boot on x86-64 (sigh)
      AK: merged with other patches
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NAndi Kleen <ak@suse.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ab144f5e
  10. 09 8月, 2007 2 次提交
    • R
      lguest: Fix Malicious Guest GDT Host Crash · 0d027c01
      Rusty Russell 提交于
      If a Guest makes hypercall which sets a GDT entry to not present, we
      currently set any segment registers using that GDT entry to 0.
      Unfortunately, this is not sufficient: there are other ways of
      altering GDT entries which will cause a fault.
      
      The correct solution to do what Linux does: let them set any GDT value
      they want and handle the #GP when popping causes a fault.  This has
      the added benefit of making our Switcher slightly more robust in the
      case of any other bugs which cause it to fault.
      
      We kill the Guest if it causes a fault in the Switcher: it's the
      Guest's responsibility to make sure it's not using segments when it
      changes them.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0d027c01
    • R
      Fix non-TSC guest clocksource lockup · 37250097
      Rusty Russell 提交于
      lguest uses a host-supplied wallclock-based clocksource when the TSC
      is not reliable.  As this is already in nanoseconds, I naively used a
      multiplier of 1 and a shift of 0.
      
      But update_wall_time() in its infinite wisdom decides to adjust the
      clock a little (where does it think it's getting a more accurate time
      from?)
      
      It will happily tweak the multiplier... to 0, then -1.
      
      So the "fix" is to use a shift of 22 like everyone else, and a
      multiplier of 1 << 22.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      37250097
  11. 29 7月, 2007 2 次提交
  12. 27 7月, 2007 3 次提交
  13. 22 7月, 2007 1 次提交
  14. 21 7月, 2007 1 次提交
  15. 20 7月, 2007 1 次提交