From: Mukesh Rathor <mukesh.rathor@oracle.com>
To: "Xen-devel@lists.xensource.com" <Xen-devel@lists.xensource.com>
Subject: [RFC PATCH 1/15]: PVH xen: turn gdb_frames/gdt_ents into union
Date: Fri, 11 Jan 2013 17:25:22 -0800 [thread overview]
Message-ID: <20130111172522.6e73d884@mantra.us.oracle.com> (raw)
PVH only needs gdtaddr and gdtsz, so a union is created. There is no
functional code change in this patch.
Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
diff -r bf249cd5f2c1 -r 278d7a933d88 tools/libxc/xc_domain_restore.c
--- a/tools/libxc/xc_domain_restore.c Tue Oct 30 18:12:11 2012 +0000
+++ b/tools/libxc/xc_domain_restore.c Fri Jan 11 16:19:40 2013 -0800
@@ -1933,15 +1933,15 @@ int xc_domain_restore(xc_interface *xch,
munmap(start_info, PAGE_SIZE);
}
/* Uncanonicalise each GDT frame number. */
- if ( GET_FIELD(ctxt, gdt_ents) > 8192 )
+ if ( GET_FIELD(ctxt, u.pv.gdt_ents) > 8192 )
{
ERROR("GDT entry count out of range");
goto out;
}
- for ( j = 0; (512*j) < GET_FIELD(ctxt, gdt_ents); j++ )
+ for ( j = 0; (512*j) < GET_FIELD(ctxt, u.pv.gdt_ents); j++ )
{
- pfn = GET_FIELD(ctxt, gdt_frames[j]);
+ pfn = GET_FIELD(ctxt, u.pv.gdt_frames[j]);
if ( (pfn >= dinfo->p2m_size) ||
(pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB) )
{
@@ -1949,7 +1949,7 @@ int xc_domain_restore(xc_interface *xch,
j, (unsigned long)pfn);
goto out;
}
- SET_FIELD(ctxt, gdt_frames[j], ctx->p2m[pfn]);
+ SET_FIELD(ctxt, u.pv.gdt_frames[j], ctx->p2m[pfn]);
}
/* Uncanonicalise the page table base pointer. */
pfn = UNFOLD_CR3(GET_FIELD(ctxt, ctrlreg[3]));
diff -r bf249cd5f2c1 -r 278d7a933d88 tools/libxc/xc_domain_save.c
--- a/tools/libxc/xc_domain_save.c Tue Oct 30 18:12:11 2012 +0000
+++ b/tools/libxc/xc_domain_save.c Fri Jan 11 16:19:40 2013 -0800
@@ -1889,15 +1889,15 @@ int xc_domain_save(xc_interface *xch, in
}
/* Canonicalise each GDT frame number. */
- for ( j = 0; (512*j) < GET_FIELD(&ctxt, gdt_ents); j++ )
+ for ( j = 0; (512*j) < GET_FIELD(&ctxt, u.pv.gdt_ents); j++ )
{
- mfn = GET_FIELD(&ctxt, gdt_frames[j]);
+ mfn = GET_FIELD(&ctxt, u.pv.gdt_frames[j]);
if ( !MFN_IS_IN_PSEUDOPHYS_MAP(mfn) )
{
ERROR("GDT frame is not in range of pseudophys map");
goto out;
}
- SET_FIELD(&ctxt, gdt_frames[j], mfn_to_pfn(mfn));
+ SET_FIELD(&ctxt, u.pv.gdt_frames[j], mfn_to_pfn(mfn));
}
/* Canonicalise the page table base pointer. */
diff -r bf249cd5f2c1 -r 278d7a933d88 xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c Tue Oct 30 18:12:11 2012 +0000
+++ b/xen/arch/x86/domain.c Fri Jan 11 16:19:40 2013 -0800
@@ -811,8 +811,8 @@ int arch_set_info_guest(
}
for ( i = 0; i < ARRAY_SIZE(v->arch.pv_vcpu.gdt_frames); ++i )
- fail |= v->arch.pv_vcpu.gdt_frames[i] != c(gdt_frames[i]);
- fail |= v->arch.pv_vcpu.gdt_ents != c(gdt_ents);
+ fail |= v->arch.pv_vcpu.gdt_frames[i] != c(u.pv.gdt_frames[i]);
+ fail |= v->arch.pv_vcpu.gdt_ents != c(u.pv.gdt_ents);
fail |= v->arch.pv_vcpu.ldt_base != c(ldt_base);
fail |= v->arch.pv_vcpu.ldt_ents != c(ldt_ents);
@@ -861,17 +861,17 @@ int arch_set_info_guest(
d->vm_assist = c(vm_assist);
if ( !compat )
- rc = (int)set_gdt(v, c.nat->gdt_frames, c.nat->gdt_ents);
+ rc = (int)set_gdt(v, c.nat->u.pv.gdt_frames, c.nat->u.pv.gdt_ents);
else
{
unsigned long gdt_frames[ARRAY_SIZE(v->arch.pv_vcpu.gdt_frames)];
- unsigned int n = (c.cmp->gdt_ents + 511) / 512;
+ unsigned int n = (c.cmp->u.pv.gdt_ents + 511) / 512;
if ( n > ARRAY_SIZE(v->arch.pv_vcpu.gdt_frames) )
return -EINVAL;
for ( i = 0; i < n; ++i )
- gdt_frames[i] = c.cmp->gdt_frames[i];
- rc = (int)set_gdt(v, gdt_frames, c.cmp->gdt_ents);
+ gdt_frames[i] = c.cmp->u.pv.gdt_frames[i];
+ rc = (int)set_gdt(v, gdt_frames, c.cmp->u.pv.gdt_ents);
}
if ( rc != 0 )
return rc;
diff -r bf249cd5f2c1 -r 278d7a933d88 xen/arch/x86/domctl.c
--- a/xen/arch/x86/domctl.c Tue Oct 30 18:12:11 2012 +0000
+++ b/xen/arch/x86/domctl.c Fri Jan 11 16:19:40 2013 -0800
@@ -1651,12 +1651,12 @@ void arch_get_info_guest(struct vcpu *v,
c(ldt_base = v->arch.pv_vcpu.ldt_base);
c(ldt_ents = v->arch.pv_vcpu.ldt_ents);
for ( i = 0; i < ARRAY_SIZE(v->arch.pv_vcpu.gdt_frames); ++i )
- c(gdt_frames[i] = v->arch.pv_vcpu.gdt_frames[i]);
- BUILD_BUG_ON(ARRAY_SIZE(c.nat->gdt_frames) !=
- ARRAY_SIZE(c.cmp->gdt_frames));
- for ( ; i < ARRAY_SIZE(c.nat->gdt_frames); ++i )
- c(gdt_frames[i] = 0);
- c(gdt_ents = v->arch.pv_vcpu.gdt_ents);
+ c(u.pv.gdt_frames[i] = v->arch.pv_vcpu.gdt_frames[i]);
+ BUILD_BUG_ON(ARRAY_SIZE(c.nat->u.pv.gdt_frames) !=
+ ARRAY_SIZE(c.cmp->u.pv.gdt_frames));
+ for ( ; i < ARRAY_SIZE(c.nat->u.pv.gdt_frames); ++i )
+ c(u.pv.gdt_frames[i] = 0);
+ c(u.pv.gdt_ents = v->arch.pv_vcpu.gdt_ents);
c(kernel_ss = v->arch.pv_vcpu.kernel_ss);
c(kernel_sp = v->arch.pv_vcpu.kernel_sp);
for ( i = 0; i < ARRAY_SIZE(v->arch.pv_vcpu.ctrlreg); ++i )
diff -r bf249cd5f2c1 -r 278d7a933d88 xen/include/public/arch-x86/xen.h
--- a/xen/include/public/arch-x86/xen.h Tue Oct 30 18:12:11 2012 +0000
+++ b/xen/include/public/arch-x86/xen.h Fri Jan 11 16:19:40 2013 -0800
@@ -157,7 +157,16 @@ struct vcpu_guest_context {
struct cpu_user_regs user_regs; /* User-level CPU registers */
struct trap_info trap_ctxt[256]; /* Virtual IDT */
unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
- unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
+ union {
+ struct {
+ /* GDT (machine frames, # ents) */
+ unsigned long gdt_frames[16], gdt_ents;
+ } pv;
+ struct {
+ /* PVH: GDTR addr and size */
+ unsigned long gdtaddr, gdtsz;
+ } pvh;
+ } u;
unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */
/* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */
next reply other threads:[~2013-01-12 1:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-12 1:25 Mukesh Rathor [this message]
2013-01-14 11:18 ` [RFC PATCH 1/15]: PVH xen: turn gdb_frames/gdt_ents into union Jan Beulich
2013-01-15 0:45 ` Mukesh Rathor
2013-01-24 14:29 ` Tim Deegan
2013-01-24 15:37 ` Jan Beulich
2013-01-24 15:45 ` Tim Deegan
2013-01-24 15:54 ` Jan Beulich
2013-01-24 16:18 ` Tim Deegan
2013-01-25 2:04 ` Mukesh Rathor
2013-01-25 9:38 ` Tim Deegan
2013-01-25 10:23 ` 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=20130111172522.6e73d884@mantra.us.oracle.com \
--to=mukesh.rathor@oracle.com \
--cc=Xen-devel@lists.xensource.com \
/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 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).