* getting a 32-bit mfn from a 32-on-64 HVM guest
@ 2010-06-20 17:45 Dan Magenheimer
2010-06-20 17:56 ` Keir Fraser
0 siblings, 1 reply; 3+ messages in thread
From: Dan Magenheimer @ 2010-06-20 17:45 UTC (permalink / raw)
To: Xen-Devel (xen-devel@lists.xensource.com)
I'm working on getting tmem working for HVM guests
(on top of Stefano's PV on HVM patch). I've discovered
that the guest mfn passed in for some tmem operations
from a 32-bit HVM guest is getting interpreted in
the following function as a 64-bit mfn, and the
upper bits are confusing the translation to a Xen mfn.
What is the "proper" way to ensure that the cmfn
is properly truncated for a 32-bit HVM guest
without truncating it for a 64-bit guest? I
have used is_pv_32on64_vcpu()... is there an equivalent
for HVM? Or do I need to do something entirely different?
Thanks,
Dan
/* from xen/common/tmem_xen.c */
static inline void *cli_mfn_to_va(tmem_cli_mfn_t cmfn,
unsigned long *pcli_mfn)
{
unsigned long cli_mfn;
p2m_type_t t;
cli_mfn = mfn_x(gfn_to_mfn(current->domain, cmfn, &t));
if (t != p2m_ram_rw)
return NULL;
if (pcli_mfn != NULL)
*pcli_mfn = cli_mfn;
return map_domain_page(cli_mfn);
}
/* following from include/public/tmem.h, look for cmfn */
typedef xen_pfn_t tmem_cli_mfn_t;
typedef XEN_GUEST_HANDLE(char) tmem_cli_va_t;
struct tmem_op {
uint32_t cmd;
int32_t pool_id;
union {
struct {
uint64_t uuid[2];
uint32_t flags;
uint32_t arg1;
} new; /* for cmd == TMEM_NEW_POOL, TMEM_AUTH, TMEM_RESTORE_NEW */
struct {
uint32_t subop;
uint32_t cli_id;
uint32_t arg1;
uint32_t arg2;
uint64_t arg3;
tmem_cli_va_t buf;
} ctrl; /* for cmd == TMEM_CONTROL */
struct {
uint64_t object;
uint32_t index;
uint32_t tmem_offset;
uint32_t pfn_offset;
uint32_t len;
tmem_cli_mfn_t cmfn; /* client machine page frame */
} gen; /* for all other cmd ("generic") */
} u;
};
typedef struct tmem_op tmem_op_t;
DEFINE_XEN_GUEST_HANDLE(tmem_op_t);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: getting a 32-bit mfn from a 32-on-64 HVM guest
2010-06-20 17:45 getting a 32-bit mfn from a 32-on-64 HVM guest Dan Magenheimer
@ 2010-06-20 17:56 ` Keir Fraser
2010-06-21 1:50 ` Dan Magenheimer
0 siblings, 1 reply; 3+ messages in thread
From: Keir Fraser @ 2010-06-20 17:56 UTC (permalink / raw)
To: Dan Magenheimer, Xen-Devel (xen-devel@lists.xensource.com)
On 20/06/2010 18:45, "Dan Magenheimer" <dan.magenheimer@oracle.com> wrote:
> What is the "proper" way to ensure that the cmfn
> is properly truncated for a 32-bit HVM guest
> without truncating it for a 64-bit guest? I
> have used is_pv_32on64_vcpu()... is there an equivalent
> for HVM? Or do I need to do something entirely different?
See the x86_64 version of arch/x86/hvm/hvm.c:hvm_do_hypercall() which uses
hvm_guest_x86_mode() to get the 'bitness' of the HVM-guest caller. You
should do the same, probably. Or even have a compat shim around your
hypercall same as others which have differences between 32- and 64-bit
struct layouts, and have the dispatch tables in hvm.c (HVM callers) and
entry.S (PV callers) dispatch to the correct entry point for the bitness of
the caller.
-- Keir
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: getting a 32-bit mfn from a 32-on-64 HVM guest
2010-06-20 17:56 ` Keir Fraser
@ 2010-06-21 1:50 ` Dan Magenheimer
0 siblings, 0 replies; 3+ messages in thread
From: Dan Magenheimer @ 2010-06-21 1:50 UTC (permalink / raw)
To: Keir Fraser, Xen-Devel (xen-devel@lists.xensource.com)
> From: Keir Fraser [mailto:keir.fraser@eu.citrix.com]
> Sent: Sunday, June 20, 2010 11:56 AM
> To: Dan Magenheimer; Xen-Devel (xen-devel@lists.xensource.com)
> Subject: Re: [Xen-devel] getting a 32-bit mfn from a 32-on-64 HVM guest
>
> On 20/06/2010 18:45, "Dan Magenheimer" <dan.magenheimer@oracle.com>
> wrote:
>
> > What is the "proper" way to ensure that the cmfn
> > is properly truncated for a 32-bit HVM guest
> > without truncating it for a 64-bit guest? I
> > have used is_pv_32on64_vcpu()... is there an equivalent
> > for HVM? Or do I need to do something entirely different?
>
> See the x86_64 version of arch/x86/hvm/hvm.c:hvm_do_hypercall() which
> uses
> hvm_guest_x86_mode() to get the 'bitness' of the HVM-guest caller. You
> should do the same, probably. Or even have a compat shim around your
> hypercall same as others which have differences between 32- and 64-bit
> struct layouts, and have the dispatch tables in hvm.c (HVM callers) and
> entry.S (PV callers) dispatch to the correct entry point for the
> bitness of
> the caller.
Thanks! The code was already in place for PV (see
tmh_get_tmemop_from_client() in include/xen/tmem_xen.h),
so I just had to add the case for HVM 32-on-64 and
it works! A little more cleanup and I'll submit the patch.
Dan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-21 1:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-20 17:45 getting a 32-bit mfn from a 32-on-64 HVM guest Dan Magenheimer
2010-06-20 17:56 ` Keir Fraser
2010-06-21 1:50 ` Dan Magenheimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).