From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Egger Subject: [PATCH] nestedhvm: ASID emulation (cleanup) Date: Wed, 13 Apr 2011 12:35:50 +0200 Message-ID: <4DA57C86.7000902@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020904090809060708090005" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --------------020904090809060708090005 Content-Type: text/plain; charset="ISO-8859-15"; format=flowed Content-Transfer-Encoding: 7bit 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 -- ---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 --------------020904090809060708090005 Content-Type: text/plain; name="xen_nh_asid_cleanup.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen_nh_asid_cleanup.diff" Content-Description: xen_nh_asid_cleanup.diff 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; --------------020904090809060708090005 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------020904090809060708090005--