Skip to contentSkip to conversation

x86/svm: Drop svm_vm{load,save}() helpers

PATCH In review Andrew Cooper 3 participants 3 messages Jun 20, 2019 – Jun 28, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/svm: Drop svm_vm{load,save}() helpers

Following on from c/s 7d161f6537 "x86/svm: Fix svm_vmcb_dump() when used in current context", there is now only a single user of svm_vmsave() remaining in the tree, with all users moved to svm_vm{load,save}_pa().

nv->nv_n1vmcx has a matching nv->nv_n1vmcx_pa which is always correct, and avoids a redundant __pa() translation behind the scenes.

With this gone, all VM{LOAD,SAVE} operations are using paddr_t's which is more efficient, so drop the svm_vm{load,save}() helpers to avoid uses of them reappearing in the future.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Boris Ostrovsky <[email protected]>
CC: Suravee Suthikulpanit <[email protected]>
CC: Brian Woods <[email protected]>

It turns out I was mistaken about how complicated this was.

---
 xen/arch/x86/hvm/svm/nestedsvm.c  | 2 +-
 xen/include/asm-x86/hvm/svm/svm.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)
xen/arch/x86/hvm/svm/nestedsvm.c +1 -1
index 35c1a04..fef124f 100644
@@ -1030,7 +1030,7 @@ nsvm_vmcb_prepare4vmexit(struct vcpu *v, struct cpu_user_regs *regs)
     struct vmcb_struct *ns_vmcb = nv->nv_vvmcx;
     struct vmcb_struct *n2vmcb = nv->nv_n2vmcx;
 
-    svm_vmsave(nv->nv_n1vmcx);
+    svm_vmsave_pa(nv->nv_n1vmcx_pa);
 
     /* Cache guest physical address of virtual vmcb
      * for VMCB Cleanbit emulation.
xen/include/asm-x86/hvm/svm/svm.h +0 -3
index 6e688a8..16a994e 100644
@@ -22,9 +22,6 @@
 
 #include <xen/types.h>
 
-#define svm_vmload(x)     svm_vmload_pa(__pa(x))
-#define svm_vmsave(x)     svm_vmsave_pa(__pa(x))
-
 static inline void svm_vmload_pa(paddr_t vmcb)
 {
     asm volatile (
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 20.06.19 at 14:06, <[email protected]> wrote:

Following on from c/s 7d161f6537 "x86/svm: Fix svm_vmcb_dump() when used in current context", there is now only a single user of svm_vmsave() remaining in the tree, with all users moved to svm_vm{load,save}_pa().

Quoted 8 lines

nv->nv_n1vmcx has a matching nv->nv_n1vmcx_pa which is always correct, and avoids a redundant __pa() translation behind the scenes.

With this gone, all VM{LOAD,SAVE} operations are using paddr_t's which is more efficient, so drop the svm_vm{load,save}() helpers to avoid uses of them reappearing in the future.

Quoted 1 line

It turns out I was mistaken about how complicated this was.

That was my hope, but it has been too long since I had last looked at the nesting code in any level of detail.

xen/include/asm-x86/hvm/svm/svm.h line 25

Quoted 10 lines
xen/include/asm-x86/hvm/svm/svm.h +0 -3
@@ -22,9 +22,6 @@
 
 #include <xen/types.h>
 
-#define svm_vmload(x)     svm_vmload_pa(__pa(x))
-#define svm_vmsave(x)     svm_vmsave_pa(__pa(x))
-
 static inline void svm_vmload_pa(paddr_t vmcb)

Down the road we may want to consider dropping the now pointless _pa suffixes.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v1 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 4 lines · Andy Cooper

Following on from c/s 7d161f6537 "x86/svm: Fix svm_vmcb_dump() when used in current context", there is now only a single user of svm_vmsave() remaining in the tree, with all users moved to svm_vm{load,save}_pa().

Quoted 8 lines

nv->nv_n1vmcx has a matching nv->nv_n1vmcx_pa which is always correct, and avoids a redundant __pa() translation behind the scenes.

With this gone, all VM{LOAD,SAVE} operations are using paddr_t's which is more efficient, so drop the svm_vm{load,save}() helpers to avoid uses of them reappearing in the future.

Quoted 44 lines

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Boris Ostrovsky <[email protected]>
CC: Suravee Suthikulpanit <[email protected]>
CC: Brian Woods <[email protected]>

It turns out I was mistaken about how complicated this was.

---
 xen/arch/x86/hvm/svm/nestedsvm.c  | 2 +-
 xen/include/asm-x86/hvm/svm/svm.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)
xen/arch/x86/hvm/svm/nestedsvm.c +1 -1
index 35c1a04..fef124f 100644
@@ -1030,7 +1030,7 @@ nsvm_vmcb_prepare4vmexit(struct vcpu *v, struct cpu_user_regs *regs)
     struct vmcb_struct *ns_vmcb = nv->nv_vvmcx;
     struct vmcb_struct *n2vmcb = nv->nv_n2vmcx;
 
-    svm_vmsave(nv->nv_n1vmcx);
+    svm_vmsave_pa(nv->nv_n1vmcx_pa);
 
     /* Cache guest physical address of virtual vmcb
      * for VMCB Cleanbit emulation.
xen/include/asm-x86/hvm/svm/svm.h +0 -3
index 6e688a8..16a994e 100644
@@ -22,9 +22,6 @@
 
 #include <xen/types.h>
 
-#define svm_vmload(x)     svm_vmload_pa(__pa(x))
-#define svm_vmsave(x)     svm_vmsave_pa(__pa(x))
-
 static inline void svm_vmload_pa(paddr_t vmcb)
 {
     asm volatile (
Signature · 1 line
2.1.4
Signature · 6 lines
Brian Woods

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel