All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Wang2 <wei.wang2@amd.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [RFC PATCH 2/2] ASID: Flush by ASID
Date: Tue, 11 Jan 2011 18:55:58 +0100	[thread overview]
Message-ID: <201101111855.58581.wei.wang2@amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 368 bytes --]

This patch implements flush by asid feature for AMD CPUs.
Thanks,
Wei

Signed-off-by: Wei Huang <wei.huang2@amd.com>
Signed-off-by: Wei Wang <wei.wang2@amd.com>
--
Advanced Micro Devices GmbH
Sitz: Dornach, Gemeinde Aschheim, 
Landkreis München Registergericht München, 
HRB Nr. 43632
WEEE-Reg-Nr: DE 12919551
Geschäftsführer:
Alberto Bozzo, Andrew Bowd

[-- Attachment #2: flush_by_asid_2.patch --]
[-- Type: text/x-diff, Size: 2180 bytes --]

diff -r 940b8760c604 xen/arch/x86/hvm/svm/asid.c
--- a/xen/arch/x86/hvm/svm/asid.c	Tue Jan 11 14:32:25 2011 +0100
+++ b/xen/arch/x86/hvm/svm/asid.c	Tue Jan 11 14:55:24 2011 +0100
@@ -26,12 +26,16 @@ void svm_asid_init(struct cpuinfo_x86 *c
 void svm_asid_init(struct cpuinfo_x86 *c)
 {
     int nasids = 0;
+    int svm_features = 0;
 
     /* Check for erratum #170, and leave ASIDs disabled if it's present. */
     if ( !cpu_has_amd_erratum(c, AMD_ERRATUM_170) )
         nasids = cpuid_ebx(0x8000000A);
-
-    hvm_asid_init(nasids, 0);
+    
+    /* We can't use cpu_has_flush_by_asid here because svm_feature_flags has
+     * been initialized yet. Use CPUID to find out instead. */
+    svm_features = cpuid_edx(0x8000000A);
+    hvm_asid_init(nasids, svm_features & (1 << SVM_FEATURE_FLUSHBYASID));
 }
 
 /*
@@ -42,7 +46,7 @@ asmlinkage void svm_asid_handle_vmrun(vo
 {
     struct vcpu *curr = current;
     struct vmcb_struct *vmcb = curr->arch.hvm_svm.vmcb;
-    bool_t need_flush = !!hvm_asid_handle_vmenter();
+    asid_action_t asid_action = hvm_asid_handle_vmenter();
 
     /* ASID 0 indicates that ASIDs are disabled. */
     if ( curr->arch.hvm_vcpu.asid == 0 )
@@ -53,7 +57,10 @@ asmlinkage void svm_asid_handle_vmrun(vo
     }
 
     vmcb_set_guest_asid(vmcb, curr->arch.hvm_vcpu.asid);
-    vmcb->tlb_control = need_flush;
+
+    /* Note: make sure asid_action value returned from hvm_asid_handle_vmenter
+    * matches SVM's definition here. */
+    curr->arch.hvm_svm.vmcb->tlb_control = asid_action;
 }
 
 /*
diff -r 940b8760c604 xen/include/asm-x86/hvm/svm/svm.h
--- a/xen/include/asm-x86/hvm/svm/svm.h	Tue Jan 11 14:32:25 2011 +0100
+++ b/xen/include/asm-x86/hvm/svm/svm.h	Tue Jan 11 14:55:24 2011 +0100
@@ -80,6 +80,7 @@ extern u32 svm_feature_flags;
 #define cpu_has_svm_svml      cpu_has_svm_feature(SVM_FEATURE_SVML)
 #define cpu_has_svm_nrips     cpu_has_svm_feature(SVM_FEATURE_NRIPS)
 #define cpu_has_svm_cleanbits cpu_has_svm_feature(SVM_FEATURE_VMCBCLEAN)
+#define cpu_has_flush_by_asid cpu_has_svm_feature(SVM_FEATURE_FLUSHBYASID)
 #define cpu_has_pause_filter  cpu_has_svm_feature(SVM_FEATURE_PAUSEFILTER)
 
 #endif /* __ASM_X86_HVM_SVM_H__ */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2011-01-11 17:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-11 17:55 Wei Wang2 [this message]
2011-01-12  8:27 ` [RFC PATCH 2/2] ASID: Flush by ASID 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=201101111855.58581.wei.wang2@amd.com \
    --to=wei.wang2@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.