All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: Tim Deegan <tim@xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	boris.ostrovsky@oracle.com, Jan Beulich <JBeulich@suse.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v5 4/9] xen/x86: populate PVHv2 Dom0 physical memory map
Date: Fri, 27 Jan 2017 12:37:13 +0000	[thread overview]
Message-ID: <20170127123713.3sltq56qtk2rf6oa@dhcp-3-221.uk.xensource.com> (raw)
In-Reply-To: <20170127111410.GA42605@deinos.phlegethon.org>

On Fri, Jan 27, 2017 at 11:14:10AM +0000, Tim Deegan wrote:
> At 05:41 -0700 on 26 Jan (1485409318), Jan Beulich wrote:
> > >>> On 19.01.17 at 18:29, <roger.pau@citrix.com> wrote:
> > > +/* Size of the VM86 TSS for virtual 8086 mode to use. */
> > > +#define HVM_VM86_TSS_SIZE   128
> > 
> > I continue to be puzzled by this value. Why 128? I think this really
> > needs to be clarified in the comment.
> 
> I was asked on IRC to do some archaeology / explain myself about this,
> so here goes.
> 
> First, the _intended_ mechanism for "real mode" guests on older VMX
> hardware is to run them in virtual 8086 mode inside the guest as much
> as possible, and emulate whenever we can't do that.
> 
> This is managed with some state in v->arch.hvm_vmx:
>  - vmx_realmode, set when the guest thinks it's in real mode. 
>  - vmx_emulate, to force emulation rather than VMENTER
>    We set this when we have exceptions to inject, as the VMX hardware
>    would try to inject them in 32-bit protected mode.
>  - vm86_segment_mask, a bitmask of segments that can't be fudged
>    to run in virtual 8086 mode.
> 
> When vmx_realmode is set, vmx_do_vmentry() DTRT: it bails out into the
> emulator if either vmx_emulate or any bit in vm86_segment_mask is set;
> otherwise it calls vmx_enter_realmode() to adjust %rflags and enters
> the guest in virtual 8086 mode.
> 
> The reason we need a TSS at all is for handling software interrupts.
> Virtual 8086 mode has two ways to handle software interrupts: stay in
> virtual 8086 mode and vector via the table @0x0, or raise #GP in 32-bit
> protected mode.  We want the first of those, so that a guest in 'real mode'
> can make BIOS calls.
> 
> The CPU uses a bitmap in the TSS to decide which method to use; we
> need all the bits in that bitmap to be clear.  In my SDM (April 2016)
> this is section 20.3.3 "Class 3 -- Software Interrupt Handling in
> Virtual-8086 Mode", table 20-2, method 5.
> 
> ---
> 
> So far so good, and AIUI the system works -- or at least it did in
> December 2008 when it was put in (8d4638d1), because emulating every
> instruction made Windows boot times so slow that we would definitely
> have noticed.
> 
> But looking at it now, I'm not convinced of exactly how.  The magic
> bitmap in the TSS is at [I/O Map Base Address] - 32, and the I/O map
> base address itself lives at offset 100.  A zero'd TSS should mean an
> I/O map at 0, and an interrupt redirection bitmap at -32, which would
> plausibly work if the TSS were 256 bytes (matching the limit set in
> Xen).  Perhaps it's only working because the 128 bytes following the
> TSS in hvmloader happen to be zeros too?

Right, so *if* this was working as intended, the interrupt bitmap would be at
HVM_PARAM_VM86_TSS - 32, which we don't guarantee to zero at all.

I've also looked at the manual, and it states that the last bit of the IO
bitmap should be filled with 1s[0], which we don't do at all. Also, what's the
expected size of the IO bitmap, 64KB?

Roger.

[0] Vol3, section 20.3.3 "Class 3-Software Interrupt Handling in Virtual-8086
Mode, Figure 20-5.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-01-27 12:37 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19 17:29 [PATCH v5 0/9] Initial PVHv2 Dom0 support Roger Pau Monne
2017-01-19 17:29 ` [PATCH v5 1/9] xen/x86: remove XENFEAT_hvm_pirqs for PVHv2 guests Roger Pau Monne
2017-01-20 18:41   ` Andrew Cooper
2017-01-23 12:28     ` Roger Pau Monne
2017-01-19 17:29 ` [PATCH v5 2/9] x86/iommu: add IOMMU entries for p2m_mmio_direct pages Roger Pau Monne
2017-01-20  6:41   ` Tian, Kevin
2017-01-20 10:28     ` Roger Pau Monne
2017-01-20 18:44   ` Andrew Cooper
2017-01-22  4:45     ` Tian, Kevin
2017-01-19 17:29 ` [PATCH v5 3/9] xen/x86: split Dom0 build into PV and PVHv2 Roger Pau Monne
2017-01-20 19:03   ` Andrew Cooper
2017-01-23 12:58     ` Roger Pau Monne
2017-01-23 12:59       ` Andrew Cooper
2017-01-20 19:13   ` Boris Ostrovsky
2017-01-20 19:27     ` Andrew Cooper
2017-01-26 11:43   ` Jan Beulich
2017-01-26 16:36     ` Roger Pau Monne
2017-01-19 17:29 ` [PATCH v5 4/9] xen/x86: populate PVHv2 Dom0 physical memory map Roger Pau Monne
2017-01-20 19:41   ` Andrew Cooper
2017-01-23 11:23     ` Jan Beulich
2017-01-23 14:11   ` Boris Ostrovsky
2017-01-23 14:43     ` Roger Pau Monne
2017-01-26 12:41   ` Jan Beulich
2017-01-27 11:14     ` Tim Deegan
2017-01-27 12:37       ` Roger Pau Monne [this message]
2017-01-27 12:51       ` Andrew Cooper
2017-01-27 13:20         ` Tim Deegan
2017-01-27 13:46           ` Andrew Cooper
2017-01-27 14:01             ` Tim Deegan
2017-01-27 14:35               ` Andrew Cooper
2017-01-27 19:43                 ` Tim Deegan
2017-01-30 10:43                   ` Jan Beulich
2017-01-30 11:06                     ` Andrew Cooper
2017-01-27 16:40           ` Jan Beulich
2017-01-27 18:06             ` Andrew Cooper
2017-02-03 13:57               ` Jan Beulich
2017-01-27 19:48             ` Tim Deegan
2017-02-02 15:38               ` Jan Beulich
2017-01-27 12:23     ` Roger Pau Monne
2017-01-27 15:11       ` Jan Beulich
2017-01-27 16:04         ` Roger Pau Monne
2017-01-27 16:29           ` Jan Beulich
2017-01-19 17:29 ` [PATCH v5 5/9] x86/hvm: add vcpu parameter to guest memory copy function Roger Pau Monne
2017-01-20 19:45   ` Andrew Cooper
2017-01-23 13:50     ` Roger Pau Monne
2017-01-26 12:51   ` Jan Beulich
2017-01-26 13:33   ` Jan Beulich
2017-01-27 14:55     ` Roger Pau Monne
2017-01-19 17:29 ` [PATCH v5 6/9] xen/x86: parse Dom0 kernel for PVHv2 Roger Pau Monne
2017-01-26 13:37   ` Jan Beulich
2017-01-27 17:22     ` Roger Pau Monne
2017-01-27 17:28       ` Roger Pau Monne
2017-01-30 10:20         ` Jan Beulich
2017-01-27 18:03       ` Roger Pau Monne
2017-01-30 10:14       ` Jan Beulich
2017-01-19 17:29 ` [PATCH v5 7/9] x86/PVHv2: fix dom0_max_vcpus so it's capped to 128 for PVHv2 Dom0 Roger Pau Monne
2017-01-19 17:32   ` Andrew Cooper
2017-01-26 13:39   ` Jan Beulich
2017-01-19 17:29 ` [PATCH v5 8/9] xen/x86: Setup PVHv2 Dom0 CPUs Roger Pau Monne
2017-01-26 13:46   ` Jan Beulich
2017-02-08 12:48     ` Roger Pau Monne
2017-02-08 13:02       ` Jan Beulich
2017-01-19 17:29 ` [PATCH v5 9/9] xen/x86: setup PVHv2 Dom0 ACPI tables Roger Pau Monne
2017-01-26 14:16   ` Jan Beulich
2017-02-08 15:10     ` Roger Pau Monne
2017-02-08 15:50       ` Jan Beulich
2017-02-08 15:58         ` Roger Pau Monne
2017-02-08 16:03           ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170127123713.3sltq56qtk2rf6oa@dhcp-3-221.uk.xensource.com \
    --to=roger.pau@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.