From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 4/5] x86/pv: Simplify access to the LDT/GDT ptes
Date: Tue, 29 Aug 2017 12:19:15 +0100 [thread overview]
Message-ID: <1504005556-30394-5-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1504005556-30394-1-git-send-email-andrew.cooper3@citrix.com>
Rename gdt_ldt_ptes() to pv_gdt_ptes() and drop the domain parameter, as it is
incorrect to use the helper with d != v->domain.
Introduce pv_ldt_ptes() to abstract away the fact that the LDT mapping is 16
slots after the GDT, and adjust the callers accordingly.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
xen/arch/x86/domain.c | 2 +-
xen/arch/x86/mm.c | 10 +++++-----
xen/include/asm-x86/domain.h | 5 +++--
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 57c44b1..dbddc53 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1591,7 +1591,7 @@ static void __context_switch(void)
if ( need_full_gdt(nd) )
{
unsigned long mfn = virt_to_mfn(gdt);
- l1_pgentry_t *pl1e = gdt_ldt_ptes(nd, n);
+ l1_pgentry_t *pl1e = pv_gdt_ptes(n);
unsigned int i;
for ( i = 0; i < NR_RESERVED_GDT_PAGES; i++ )
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index c41ed1b..efcddd3 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -629,9 +629,9 @@ static void invalidate_shadow_ldt(struct vcpu *v, int flush)
goto out;
v->arch.pv_vcpu.shadow_ldt_mapcnt = 0;
- pl1e = gdt_ldt_ptes(v->domain, v);
+ pl1e = pv_ldt_ptes(v);
- for ( i = 16; i < 32; i++ )
+ for ( i = 0; i < 16; i++ )
{
if ( !(l1e_get_flags(pl1e[i]) & _PAGE_PRESENT) )
continue;
@@ -701,7 +701,7 @@ bool map_ldt_shadow_page(unsigned int offset)
return false;
}
- pl1e = &gdt_ldt_ptes(d, v)[(offset >> PAGE_SHIFT) + 16];
+ pl1e = &pv_ldt_ptes(v)[offset >> PAGE_SHIFT];
l1e_add_flags(gl1e, _PAGE_RW);
spin_lock(&v->arch.pv_vcpu.shadow_ldt_lock);
@@ -4379,7 +4379,7 @@ void destroy_gdt(struct vcpu *v)
unsigned long pfn, zero_pfn = PFN_DOWN(__pa(zero_page));
v->arch.pv_vcpu.gdt_ents = 0;
- pl1e = gdt_ldt_ptes(v->domain, v);
+ pl1e = pv_gdt_ptes(v);
for ( i = 0; i < FIRST_RESERVED_GDT_PAGE; i++ )
{
pfn = l1e_get_pfn(pl1e[i]);
@@ -4424,7 +4424,7 @@ long set_gdt(struct vcpu *v,
/* Install the new GDT. */
v->arch.pv_vcpu.gdt_ents = entries;
- pl1e = gdt_ldt_ptes(d, v);
+ pl1e = pv_gdt_ptes(v);
for ( i = 0; i < nr_pages; i++ )
{
v->arch.pv_vcpu.gdt_frames[i] = frames[i];
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index c10522b..4999030 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -432,9 +432,10 @@ struct arch_domain
#define gdt_ldt_pt_idx(v) \
((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT))
-#define gdt_ldt_ptes(d, v) \
- ((d)->arch.pv_domain.gdt_ldt_l1tab[gdt_ldt_pt_idx(v)] + \
+#define pv_gdt_ptes(v) \
+ ((v)->domain->arch.pv_domain.gdt_ldt_l1tab[gdt_ldt_pt_idx(v)] + \
(((v)->vcpu_id << GDT_LDT_VCPU_SHIFT) & (L1_PAGETABLE_ENTRIES - 1)))
+#define pv_ldt_ptes(v) (pv_gdt_ptes(v) + 16)
struct pv_vcpu
{
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-08-29 11:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-29 11:19 [PATCH 0/5] x86: Misc cleanup and improvements Andrew Cooper
2017-08-29 11:19 ` [PATCH 1/5] x86/pv: Switch {fill, zap}_ro_mpt() to using mfn_t Andrew Cooper
2017-08-29 11:52 ` Tim Deegan
2017-08-29 12:01 ` George Dunlap
2017-08-29 12:17 ` Wei Liu
2017-08-29 14:00 ` Jan Beulich
2017-08-29 11:19 ` [PATCH 2/5] x86/pv: map_ldt_shadow_page() cleanup Andrew Cooper
2017-08-29 12:35 ` Wei Liu
2017-08-29 14:14 ` Jan Beulich
2017-08-29 14:54 ` Andrew Cooper
2017-08-29 15:57 ` [PATCH v2 " Andrew Cooper
2017-08-30 8:21 ` Jan Beulich
2017-08-29 11:19 ` [PATCH 3/5] x86/pv: Consistently use typesafe helpers in all files Andrew Cooper
2017-08-29 13:39 ` Wei Liu
2017-08-29 14:19 ` Jan Beulich
2017-08-29 11:19 ` Andrew Cooper [this message]
2017-08-29 13:43 ` [PATCH 4/5] x86/pv: Simplify access to the LDT/GDT ptes Wei Liu
2017-08-29 14:23 ` Jan Beulich
2017-08-29 11:19 ` [PATCH 5/5] x86/percpu: Misc cleanup Andrew Cooper
2017-08-29 13:44 ` Wei Liu
2017-08-29 14:24 ` 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=1504005556-30394-5-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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 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).