From: Christoph Egger <Christoph.Egger@amd.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH] nestedhvm: ASID emulation (cleanup)
Date: Wed, 13 Apr 2011 12:35:50 +0200 [thread overview]
Message-ID: <4DA57C86.7000902@amd.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 496 bytes --]
Cleanup for ASID emulation:
- Use C99 integer types for asid numbers
- asid.c: consistently use 'v' instead of 'curr'
- Introduce svm_invlpga() used in ASID emulation patch
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
--
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
[-- Attachment #2: xen_nh_asid_cleanup.diff --]
[-- Type: text/plain, Size: 3599 bytes --]
diff -r d1677c0438fb -r 5cd1060fb63e xen/arch/x86/hvm/asid.c
--- a/xen/arch/x86/hvm/asid.c
+++ b/xen/arch/x86/hvm/asid.c
@@ -48,9 +48,9 @@
/* Per-CPU ASID management. */
struct hvm_asid_data {
- u64 core_asid_generation;
- u32 next_asid;
- u32 max_asid;
+ uint64_t core_asid_generation;
+ uint32_t next_asid;
+ uint32_t max_asid;
bool_t disabled;
};
@@ -58,7 +58,7 @@ static DEFINE_PER_CPU(struct hvm_asid_da
void hvm_asid_init(int nasids)
{
- static s8 g_disabled = -1;
+ static int8_t g_disabled = -1;
struct hvm_asid_data *data = &this_cpu(hvm_asid_data);
data->max_asid = nasids - 1;
@@ -104,7 +104,7 @@ void hvm_asid_flush_core(void)
bool_t hvm_asid_handle_vmenter(void)
{
- struct vcpu *curr = current;
+ struct vcpu *v = current;
struct hvm_asid_data *data = &this_cpu(hvm_asid_data);
/* On erratum #170 systems we must flush the TLB.
@@ -113,7 +113,7 @@ bool_t hvm_asid_handle_vmenter(void)
goto disabled;
/* Test if VCPU has valid ASID. */
- if ( curr->arch.hvm_vcpu.asid_generation == data->core_asid_generation )
+ if ( v->arch.hvm_vcpu.asid_generation == data->core_asid_generation )
return 0;
/* If there are no free ASIDs, need to go to a new generation */
@@ -126,17 +126,17 @@ bool_t hvm_asid_handle_vmenter(void)
}
/* Now guaranteed to be a free ASID. */
- curr->arch.hvm_vcpu.asid = data->next_asid++;
- curr->arch.hvm_vcpu.asid_generation = data->core_asid_generation;
+ v->arch.hvm_vcpu.asid = data->next_asid++;
+ v->arch.hvm_vcpu.asid_generation = data->core_asid_generation;
/*
* When we assign ASID 1, flush all TLB entries as we are starting a new
* generation, and all old ASID allocations are now stale.
*/
- return (curr->arch.hvm_vcpu.asid == 1);
+ return (v->arch.hvm_vcpu.asid == 1);
disabled:
- curr->arch.hvm_vcpu.asid = 0;
+ v->arch.hvm_vcpu.asid = 0;
return 0;
}
diff -r d1677c0438fb -r 5cd1060fb63e xen/include/asm-x86/hvm/svm/asid.h
--- a/xen/include/asm-x86/hvm/svm/asid.h
+++ b/xen/include/asm-x86/hvm/svm/asid.h
@@ -34,10 +34,7 @@ static inline void svm_asid_g_invlpg(str
{
#if 0
/* Optimization? */
- asm volatile (".byte 0x0F,0x01,0xDF \n"
- : /* output */
- : /* input */
- "a" (g_vaddr), "c"(v->arch.hvm_svm.vmcb->guest_asid) );
+ svm_invlpga(g_vaddr, v->arch.hvm_svm.vmcb->guest_asid);
#endif
/* Safe fallback. Take a new ASID. */
diff -r d1677c0438fb -r 5cd1060fb63e xen/include/asm-x86/hvm/svm/svm.h
--- a/xen/include/asm-x86/hvm/svm/svm.h
+++ b/xen/include/asm-x86/hvm/svm/svm.h
@@ -60,6 +60,15 @@ static inline void svm_vmsave(void *vmcb
: : "a" (__pa(vmcb)) : "memory" );
}
+static inline void svm_invlpga(unsigned long vaddr, uint32_t asid)
+{
+ asm volatile (
+ ".byte 0x0f,0x01,0xdf"
+ : /* output */
+ : /* input */
+ "a" (vaddr), "c" (asid));
+}
+
unsigned long *svm_msrbit(unsigned long *msr_bitmap, uint32_t msr);
void __update_guest_eip(struct cpu_user_regs *regs, unsigned int inst_len);
diff -r d1677c0438fb -r 5cd1060fb63e xen/include/asm-x86/hvm/vcpu.h
--- a/xen/include/asm-x86/hvm/vcpu.h
+++ b/xen/include/asm-x86/hvm/vcpu.h
@@ -100,8 +100,8 @@ struct hvm_vcpu {
bool_t hcall_preempted;
bool_t hcall_64bit;
- u64 asid_generation;
- u32 asid;
+ uint64_t asid_generation;
+ uint32_t asid;
u32 msr_tsc_aux;
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2011-04-13 10:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-13 10:35 Christoph Egger [this message]
2011-04-13 13:06 ` [PATCH] nestedhvm: ASID emulation (cleanup) Keir Fraser
2011-04-13 13:20 ` Christoph Egger
2011-04-13 13:28 ` Keir Fraser
2011-04-13 14:27 ` Christoph Egger
2011-04-13 13:49 ` Christoph Egger
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=4DA57C86.7000902@amd.com \
--to=christoph.egger@amd.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 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.