All of lore.kernel.org
 help / color / mirror / Atom feed
* RE: 32/64-bit hypercall interface
@ 2005-09-29 13:56 Ian Pratt
  2005-09-29 18:17 ` Hollis Blanchard
  2005-10-03 18:18 ` Hollis Blanchard
  0 siblings, 2 replies; 48+ messages in thread
From: Ian Pratt @ 2005-09-29 13:56 UTC (permalink / raw)
  To: Jimi Xenidis, Keir Fraser; +Cc: xen-devel, Hollis Blanchard

> Anyway, since this is a Xen/Kernel header, perhpas we can 
> create a type that represent the Xen/Kernel machine-register size?

Since we're only talking about dom0 ops, it wouldn't be unreasonable to
turn all the long's into u64's. This would be pretty straightforward,
arguably easier than bothering with a u_reg type or similar.

Since the dom0_op interface is not guaranteed stable in the 3.0 series
[we assume you have matched tools and hypervisor] we don't have to get
this in before 3.0.0. However, it's a pretty simple change and if
someone who really cared were to knock up a tested patch immediately
we'd potentially consider it.

Ian

^ permalink raw reply	[flat|nested] 48+ messages in thread
* RE: 32/64-bit hypercall interface
@ 2005-10-04 21:51 Nakajima, Jun
  2005-10-04 22:47 ` Hollis Blanchard
  0 siblings, 1 reply; 48+ messages in thread
From: Nakajima, Jun @ 2005-10-04 21:51 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: Jeremy Katz, xen-devel, Ian Pratt

Hollis Blanchard wrote:
> On Monday 03 October 2005 16:24, Nakajima, Jun wrote:
>> Hollis Blanchard wrote:
>>> As mentioned previously, this is the approach Linux uses
>>> (linux/fs/compat_ioctl.c), and it seems less than ideal to me. Since
>>> we have the ability to fix it now (i.e. make the 32-bit and 64-bit
>>> ABI identical), shouldn't we do that rather than this
>>> copying/munging layer?
>> 
>> The 32-bit and 64-bit hypercall ABI cannot be identical on x86
>> because of the generic ABI difference between 32-bit and 64-bit.
> 
> I am not talking about the standard ABI used by the compiler (ppc32
> and ppc64 use different ABIs as well). I am talking about the
> hypervisor/tools and hypervisor/kernel ABI.
> 
> If the hypervisor ABI does not contain types that change size, it
> will be identical for both 32- and 64-bit users.
> 
Okay, I understand what you need. How about the data layout? That's not
so trivial to have the identical ones. 
For example, the following one would have different data layout on
32-bit and 64-bit. 

typedef struct vcpu_time_info {
    /*
     * Updates to the following values are preceded and followed by an
     * increment of 'version'. The guest can therefore detect updates by
     * looking for changes to 'version'. If the least-significant bit of
     * the version number is set then an update is in progress and the
guest
     * must wait to read a consistent set of values.
     * The correct way to interact with the version number is similar to
     * Linux's seqlock: see the implementations of
read_seqbegin/read_seqretry.
     */
    u32 version;
    u64 tsc_timestamp;   /* TSC at last update of time vals.  */
    u64 system_time;     /* Time, in nanosecs, since boot.    */
    /*
     * Current system time:
     *   system_time + ((tsc - tsc_timestamp) << tsc_shift) *
tsc_to_system_mul
     * CPU frequency (Hz):
     *   ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift
     */
    u32 tsc_to_system_mul;
    s8  tsc_shift;
} vcpu_time_info_t;


> If you meant something else when you said "generic ABI difference,"
> could you explain?

I meant basically the "standard ABI", such as, parameter passing, i.e.
which registers are used to pass which arguments. x86_64 xenlinux runs
in ring3, and hypercalls are not so different from system calls in terms
of the mechanism/implementation. Then when we use fast system calls, we
can use the compiler convention to minimize save/restore of the
registers.

Jun
---
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 48+ messages in thread
* RE: 32/64-bit hypercall interface
@ 2005-10-04 16:03 Nakajima, Jun
  2005-10-04 16:45 ` Andi Kleen
  0 siblings, 1 reply; 48+ messages in thread
From: Nakajima, Jun @ 2005-10-04 16:03 UTC (permalink / raw)
  To: ak; +Cc: Jeremy Katz, xen-devel, Ian Pratt

ak@suse.de wrote:
> "Nakajima, Jun" <jun.nakajima@intel.com> writes:
>> 
>> The 32-bit and 64-bit hypercall ABI cannot be identical on x86
>> because of the generic ABI difference between 32-bit and 64-bit.
> 
> You use a custom ABI for hypercalls anyways, so you can define
> it to be the same with some care. That is the approach that is
> used by some newer subsystems in the Linux kernel.
> 
In 32-bit, there are a couple of different instructions used for system
calls, e.g. "int N", sysenter, and syscall. Some x86 CPUs support only
sysenter, and some syscall, and "int N" is always available and it is
the one used for 32-bit hypercalls. In 64-bit, the situation is much
better, and we are using syscall for hypercalls, which is always
available and can be more efficient than "int N". 

I don't think we should use "int N" sacrificing the good feature for
64-bit when we can handle 32-bit hypercalls using a compatibility layer.
I also think using the existing ABI convention is much better whenever
possible and appropriate because we don't need to re-invent the wheel.
After all, the only difference between system call and hyper call
basically is the system/hypercall number.

> In my experience even people with the best intentions tend to get that
> wrong at some point because there are some subtle issues so having the
> additional safety net of a compat layer is still a good idea. It would
> only emulate the ones that went wrong.
> 
> -Andi

I agree. 

Jun
---
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 48+ messages in thread
* RE: 32/64-bit hypercall interface
@ 2005-10-03 22:03 Ian Pratt
  2005-10-04 18:05 ` Hollis Blanchard
  0 siblings, 1 reply; 48+ messages in thread
From: Ian Pratt @ 2005-10-03 22:03 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: Jeremy Katz, xen-devel, Ian Pratt, Nakajima, Jun

 > However, doesn't that same argument apply to correcting the 
> ABI in the first place? Shadow page tables will overshadow 
> the performance impact of making the ABI 32/64-bit clean.
> 
> In fact, even a plain old hypercall will also overshadow that 
> performance impact, both in terms of cycle count and cache footprint.
> 
> So if your choice then is between a compatibility translation 
> layer and altering the interface, I think it's pretty clear 
> that changing the interface will result in the least amount 
> of additional code (and associated long-term code maintenance).

This would result in doubling the size of the all the p2m and m2p
tables, which I really don't think would be sensible: the physcial
memory consumed would be somewhat annoying, but we'd also have to rejig
the virtual memory layout to accommodate the larger tables (consuming
more lowmem) and this really doesn't make sense this late in the 3.0 dev
cycle. We'd also double the cache foot print of some quite performance
critical operations. You don't need many cache misses to dominate the
cost of a system call...


Ian

^ permalink raw reply	[flat|nested] 48+ messages in thread
* RE: 32/64-bit hypercall interface
@ 2005-10-03 21:24 Nakajima, Jun
  2005-10-04 12:11 ` Andi Kleen
  2005-10-04 16:15 ` Hollis Blanchard
  0 siblings, 2 replies; 48+ messages in thread
From: Nakajima, Jun @ 2005-10-03 21:24 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: Jeremy Katz, xen-devel, Ian Pratt

Hollis Blanchard wrote:
> On Monday 03 October 2005 14:11, Nakajima, Jun wrote:
>> In terms of ABI/API, since Xen needs to disiguish 32-bit or 64-bit
>> guests anyway at runtime, I don't think we don't need to change the
>> size of any types at this point (i.e. before 3.0).
> 
> You would instead propose a compatibility layer in Xen? So when a
> hypercall from a 32-bit guest arrives at a 64-bit hypervisor, Xen
> code converts the 32-bit structure into a 64-bit one and passes that
> pointer on to the rest of Xen? And then for return values you'd
> convert the other way. Hmm, and of course you wouldn't be able to
> pass 64-bit addresses back, such as via dom0_tbufcontrol_t.

I don't think dom0_tbufcontrol_t is a good example (as dicussed). Do you
have other examples?

> 
> As mentioned previously, this is the approach Linux uses
> (linux/fs/compat_ioctl.c), and it seems less than ideal to me. Since
> we have the ability to fix it now (i.e. make the 32-bit and 64-bit
> ABI identical), shouldn't we do that rather than this copying/munging
> layer? 

The 32-bit and 64-bit hypercall ABI cannot be identical on x86 because
of the generic ABI difference between 32-bit and 64-bit. 

Jun
---
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 48+ messages in thread
* RE: 32/64-bit hypercall interface
@ 2005-10-03 19:56 Ian Pratt
  2005-10-03 20:04 ` Jeremy Katz
                   ` (2 more replies)
  0 siblings, 3 replies; 48+ messages in thread
From: Ian Pratt @ 2005-10-03 19:56 UTC (permalink / raw)
  To: Hollis Blanchard, Nakajima, Jun; +Cc: Jeremy Katz, xen-devel, Ian Pratt

> You would instead propose a compatibility layer in Xen? So 
> when a hypercall from a 32-bit guest arrives at a 64-bit 
> hypervisor, Xen code converts the 32-bit structure into a 
> 64-bit one and passes that pointer on to the rest of Xen? And 
> then for return values you'd convert the other way. Hmm, and 
> of course you wouldn't be able to pass 64-bit addresses back, 
> such as via dom0_tbufcontrol_t.

The dom0 API is a xen <-> tools API. That's *not* part of the gen guest
API.

Needing 64 bit *capable* tools for a 64 bit hypevisor is clearly a
requirement. [The fact that Power wants to implement 64 bit capable
tools as a 32 bit user space binary is totally orthogonal (and some
might say slightly perverse)]  
 
> As mentioned previously, this is the approach Linux uses 
> (linux/fs/compat_ioctl.c), and it seems less than ideal to 
> me. Since we have the ability to fix it now (i.e. make the 
> 32-bit and 64-bit ABI identical), shouldn't we do that rather 
> than this copying/munging layer?

Although I wouldn't object to using u64 everywhere in the tools (dom0)
API, I most certainly would object to using it everywhere in the 32 bit
x86 guest API as it would hurt performance and waste memory.
*Definitely*.

Just changing the tools API to all u64 seems pointless, as if you're
using a 64 bit hypervisor it seems perfectly reasonable to insist on
using 64 bit tools -- every other system binary on your 64 bit
redhat/suse install is going to be specially compiled for 64 bit, so why
not yout hypervisor tools! 

If we're going to make a change at all, switching to using ureg (or
similar) rather than 'long' is the thing to do to. This makes the job of
implementing some future compat layer very slightly easier, and helps
the Power guys do their funky 64-bit-tools-as-a-32-bit-binary thing. [*]
 
Ian

[*] implementing a hypercall compat layer is trivial compared to other
overheads you'd have (like shadow page tables). 

^ permalink raw reply	[flat|nested] 48+ messages in thread
* RE: 32/64-bit hypercall interface
@ 2005-10-03 19:11 Nakajima, Jun
  2005-10-03 19:28 ` Hollis Blanchard
  0 siblings, 1 reply; 48+ messages in thread
From: Nakajima, Jun @ 2005-10-03 19:11 UTC (permalink / raw)
  To: Jeremy Katz; +Cc: xen-devel, Ian Pratt, Hollis Blanchard

Jeremy Katz wrote:
> On Sat, 2005-10-01 at 11:25 -0700, Nakajima, Jun wrote:
>> Jeremy Katz wrote:
>>> On Fri, 2005-09-30 at 17:42 +0100, Keir Fraser wrote:
>>>> There's the rub: we don't expect to ever want to provide 32-bit x86
>>>> ABI compatibility on 64-bit x86 Xen. We will not be supporting
>>>> 32-bit paravirtualised guests on 64-bit x86 Xen,
>>> 
>>> ... which I've previously said and continue to think is going to be
>>> something that will eventually be regretted.  People are going to
>>> want to continue to run in a 32bit OS for legacy reasons for quite
>>> a while (even with the compatibility you get on x86_64).  Making it
>>> so they can't do mix and match of 32 and 64 bit guests on a single
>>> host is going to significantly reduce the utility of Xen.
> 
>> That's mostly because of the H/W issues. One thing we could do there
>> is to run such  paravirtualised 32-bit guests in compatibility mode.
>> But they would need to use 4-level page tables, and there are other
>> minor differences. So those 32-bit guests wouldn't be really same as
>> the ones running on 32-bit Xen. I'm not sure that's what you wanted,
>> but it's doable.
> 
> You really want to get to the same 32bit paravirt guest being used
> regardless of what HV flavor you're running.  Otherwise, you're in
> for a compatibility nitemare.  What dictates that the guest has to
> know about the 4 level page tables?  That's like saying that your
> 32bit binaries running on 64bit Linux need to know that there is a
> larger address space when instead that gets handled by the kernel.
> 

I fully agree that the same binary of 32bit paravirt guest be used
regardless of the HV flavor (i.e. 32-bit or 64-bit). 

If we get the shadow mode working for those 32-bit paravirt guests, we
could avoid using 4-level page tables in the guest kernel (although the
processor actually uses 4-level page tables). In that case, however, we
will lose the good optimizations for paravirt guests, such as writeable
page tables and "late pin, early unpin." (but then we get the
save/restore/migration feature) There are other areas to look at, such
as, ring1 vs. ring3, but I think we can handle those in Xen.

>> I think a better way is to utilize H/W-based virtualization such as
>> Intel Virtualization Technology (VT) or AMD's Pacifica. That way we
>> should be able to use the same binaries (thus ABI) for both 32-bit
>> non-PAE and PAE domU on 64-bit x86 Xen. With H/W-based
>> virtualization we can run those 32-bit guests cleanly in 32-bit on
>> 64-bit Xen. 32-bit hypercalls from such 32-bit guests should be
>> intercepted by a 32-bit ring0 component that converts "int 0x82"
>> based ones to VMCALL or VMMCALL sent to 64-bit Xen (because such
>> software interrupts won't cause VMEXIT). There are other issues like
>> impacts to the memory management in Xen, but I think those can be
>> handled as special cases of shadow mode (i.e. don't make shadow
>> pages). I don't think it would increase the utility of Xen right
>> away (because this requires new processors), but it might be a
>> sensible thing to do in the near future. 
> 
> Right, the problem is that people have bought hardware and they're
> going to want to use it.  I think that having things work on the
> hardware I've already purchased will help to give people a much
> better migration path for the future.  If I'm going to have to run my
> legacy 32bit stuff on a different machine anyway, then I can feel
> more free to look at other platforms for my "future" stuff.
> 
> Jeremy

That's a very good point, and that way we could provide more complete
32-bit compatibility than the one we get on x86_64 Linux.

In terms of ABI/API, since Xen needs to disiguish 32-bit or 64-bit
guests anyway at runtime, I don't think we don't need to change the size
of any types at this point (i.e. before 3.0).

Jun
---
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 48+ messages in thread
* RE: 32/64-bit hypercall interface
@ 2005-10-02 21:21 Ian Pratt
  0 siblings, 0 replies; 48+ messages in thread
From: Ian Pratt @ 2005-10-02 21:21 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: Jimi Xenidis, xen-devel


> start_info_t: tools, kernel
> xen_parameters_info_t: tools, hypervisor
> gnttab_setup_table_t: kernel, hypervisor
> gnttab_transfer_t: kernel, hypervisor
> struct xen_memory_reservation: tools, kernel, hypervisor 
> struct t_rec: tools, hypervisor struct t_buf: tools, hypervisor
> 
> (This was just a quick grep for "long" in xen/include/public.)
> 
> The tools/hypervisor interface seems to be the most important 
> at the moment. I don't know if anybody has plans to do 32-bit 
> kernel on a 64-bit hypervisor... 
> but why not enable it while we're in there?

There's rather more to running a 32 bit x86 xen guest on a 64 bit
hypervisor then just worrying about the header files. I wouldn't rule
out ever doing it, but there'll be a significant performance cost (e.g.
it will require shadow pagetables) and a significant amount of work.

The hypervisor to guest interface is obviously performance critical, and
just changing everything into a 64 bit quantity certainly would not make
sense from a memory usage, cache footprint and instruction count point
of view. Looking through the public guest interface, the current use of
'long' to get 32 bit quantities on x86_32 and 64 on x86_64 actually
makes good sense.

However, I don't think we should be using 'long' directly in public
headers as it makes it harder to override. For example, if we ever
support 32 bit guests on a 64 bit hypervisor we may want to use multiple
compilation to build a compatibility layer or such like. We should
probably typedef something like 'ureg' that we could override as
appropriate. This would also enable the Power folks to build a 32 bit
binary tools for a 64 bit hypervisor.

[I think I favour using a single typedef like 'ureg' rather than coming
up coming up with different names for all of the different uses of
'long' as the latter seems faorly pointless]

However, since we're not actually changing the size of any types, this
change isn't essential to rush through before 3.0, though it might be
nice as it should be very low risk.

Ian

^ permalink raw reply	[flat|nested] 48+ messages in thread
* RE: 32/64-bit hypercall interface
@ 2005-10-01 18:25 Nakajima, Jun
  2005-10-03 16:11 ` Jeremy Katz
  0 siblings, 1 reply; 48+ messages in thread
From: Nakajima, Jun @ 2005-10-01 18:25 UTC (permalink / raw)
  To: Jeremy Katz, xen-devel; +Cc: Ian Pratt, Hollis Blanchard

Jeremy Katz wrote:
> On Fri, 2005-09-30 at 17:42 +0100, Keir Fraser wrote:
>> There's the rub: we don't expect to ever want to provide 32-bit x86
>> ABI compatibility on 64-bit x86 Xen. We will not be supporting 32-bit
>> paravirtualised guests on 64-bit x86 Xen,
> 
> ... which I've previously said and continue to think is going to be
> something that will eventually be regretted.  People are going to want
> to continue to run in a 32bit OS for legacy reasons for quite a while
> (even with the compatibility you get on x86_64).  Making it so they
> can't do mix and match of 32 and 64 bit guests on a single host is
> going to significantly reduce the utility of Xen.
> 
> Jeremy
> 
> 
Jeremy, Hi

That's mostly because of the H/W issues. One thing we could do there is
to run such  paravirtualised 32-bit guests in compatibility mode. But
they would need to use 4-level page tables, and there are other minor
differences. So those 32-bit guests wouldn't be really same as the ones
running on 32-bit Xen. I'm not sure that's what you wanted, but it's
doable.

I think a better way is to utilize H/W-based virtualization such as
Intel Virtualization Technology (VT) or AMD's Pacifica. That way we
should be able to use the same binaries (thus ABI) for both 32-bit
non-PAE and PAE domU on 64-bit x86 Xen. With H/W-based virtualization we
can run those 32-bit guests cleanly in 32-bit on 64-bit Xen. 32-bit
hypercalls from such 32-bit guests should be intercepted by a 32-bit
ring0 component that converts "int 0x82" based ones to VMCALL or VMMCALL
sent to 64-bit Xen (because such software interrupts won't cause
VMEXIT). There are other issues like impacts to the memory management in
Xen, but I think those can be handled as special cases of shadow mode
(i.e. don't make shadow pages). I don't think it would increase the
utility of Xen right away (because this requires new processors), but it
might be a sensible thing to do in the near future.

For full-virutalization, today we can mix 32 and 64 bit guests on x86_64
Xen (as in the xen-unstable tree) when the H/W-based virtualization is
present on the machine.

Jun
---
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 48+ messages in thread
* 32/64-bit hypercall interface
@ 2005-09-28 21:36 Hollis Blanchard
  2005-09-29  9:00 ` Keir Fraser
  0 siblings, 1 reply; 48+ messages in thread
From: Hollis Blanchard @ 2005-09-28 21:36 UTC (permalink / raw)
  To: xen-devel; +Cc: Jimi Xenidis

I was looking at the definition of privcmd_hypercall:
typedef struct privcmd_hypercall
{
    unsigned long op;
    unsigned long arg[5];
} privcmd_hypercall_t;

For ppc64, we are using 32-bit management tools, so this is a problem: they 
will create structs where long is 32 bits, and the (64-bit) kernel and 
hypervisor will expect structs where long is 64 bits.

The standard (and awkward) way of dealing with the privcmd ioctl is to create 
an in-kernel privcmd_hypercall_t, copy the 32-bit values into it field by 
field, and then pass *that* struct on to privcmd_ioctl(). Of course, that's 
only for legacy interfaces; for all new interfaces, we can just design them 
properly so that their size and alignment doesn't change.

There are also longs in some of the dom0_op sub-structures. For example:
typedef struct {
    /* IN variables. */
    domid_t       domain;
    unsigned long max_memkb;
} dom0_setdomainmaxmem_t;

I suggest that all longs in these structures be converted to u32.

-- 
Hollis Blanchard
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2005-10-05 10:22 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-29 13:56 32/64-bit hypercall interface Ian Pratt
2005-09-29 18:17 ` Hollis Blanchard
2005-09-29 20:12   ` Hollis Blanchard
2005-09-29 22:26     ` Keir Fraser
2005-09-29 22:43     ` Keir Fraser
2005-09-30  0:54       ` Andrei Petrov
2005-09-30  8:03         ` Keir Fraser
2005-09-30 15:38           ` Jimi Xenidis
2005-09-30 20:05             ` Ronald G Minnich
2005-09-30 20:28               ` Hollis Blanchard
2005-09-30 20:39                 ` Ronald G Minnich
2005-09-30 15:39           ` Hollis Blanchard
2005-09-30 15:45             ` Keir Fraser
2005-09-30 16:34               ` Hollis Blanchard
2005-09-30 16:42                 ` Keir Fraser
2005-09-30 17:03                   ` Hollis Blanchard
2005-10-01  1:33                   ` Jeremy Katz
2005-10-03 19:34                   ` Kip Macy
2005-09-30 16:44                 ` David
2005-09-30 16:44                   ` Keir Fraser
2005-09-30 16:57                   ` Hollis Blanchard
2005-09-30 16:55               ` Andrei Petrov
2005-10-03 18:18 ` Hollis Blanchard
  -- strict thread matches above, loose matches on Subject: below --
2005-10-04 21:51 Nakajima, Jun
2005-10-04 22:47 ` Hollis Blanchard
2005-10-04 16:03 Nakajima, Jun
2005-10-04 16:45 ` Andi Kleen
2005-10-03 22:03 Ian Pratt
2005-10-04 18:05 ` Hollis Blanchard
2005-10-05 10:22   ` Keir Fraser
2005-10-03 21:24 Nakajima, Jun
2005-10-04 12:11 ` Andi Kleen
2005-10-04 16:15 ` Hollis Blanchard
2005-10-03 19:56 Ian Pratt
2005-10-03 20:04 ` Jeremy Katz
2005-10-03 21:11 ` Hollis Blanchard
2005-10-03 22:00   ` Keir Fraser
2005-10-04 16:27     ` Hollis Blanchard
2005-10-04 12:08 ` Andi Kleen
2005-10-03 19:11 Nakajima, Jun
2005-10-03 19:28 ` Hollis Blanchard
2005-10-02 21:21 Ian Pratt
2005-10-01 18:25 Nakajima, Jun
2005-10-03 16:11 ` Jeremy Katz
2005-09-28 21:36 Hollis Blanchard
2005-09-29  9:00 ` Keir Fraser
2005-09-29 12:41   ` Jimi Xenidis
2005-09-29 13:13     ` Keir Fraser

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.