[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] x86/hvm: Improve hvm_set_guest_pat() code generation
- To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Thu, 13 Jan 2022 13:50:35 +0000
- Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Thu, 13 Jan 2022 13:51:34 +0000
- Ironport-data: A9a23:InHIaa34T8g8hmE2rvbD5Qd2kn2cJEfYwER7XKvMYLTBsI5bpzxTy 2sWXj2OOq2JZzP2LtolYdni9kkG78KEydZnHAJkpC1hF35El5HIVI+TRqvS04J+DSFhoGZPt Zh2hgzodZhsJpPkS5PE3oHJ9RGQ74nRLlbHILOCanAZqTNMEn9700o6wrVh2OaEvPDia++zk YKqyyHgEAfNNw5cagr4PIra9XuDFNyr0N8plgRWicJj5TcypFFMZH4rHomjLmOQf2VhNrXSq 9Avbl2O1jixEx8FUrtJm1tgG6EAaua60QOm0hK6V0U+6/TrS+NbPqsTbZIhhUlrZzqhg+p/0 9VOvLeKUgo7J6rAws0kcztADHQrVUFG0OevzXmXtMWSywvNcmf2wuUoB0YzVWEa0r8pWycUr 6VecW1TKEDY7w616OvTpu1Er8IvNsT0eqgYvWlt12rxBvc6W5HTBa7N4Le02R9u35AVQqeDO 6L1bxJjSgjfXA1fNW0XDasfpsi22FfdQzRX/Qf9Sa0fvDGIkV0ZPKLWGMXRUsyHQ4NShEnwj kDs8nn9AxoaHMeC0jfD+XWp7sffkCW+VI8MGbmQ8v9xnEbV1mEVEAcRV1awvb++kEHWZj5EA xVKoGx09/F0rRH1CImmN/GlnJKalgImVcFQEOQR0hqA2LPT71ywP0gmViEUPbTKq/QKbTA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OCu0A8BOLRDpKBQcDX4MOk2J/K0xxQDXKWWKosVm1h37F HSxUzzdLzyp8UO8G02WSlCCoVrWaRgWdAh1hKsbVboQAbgYBVlJEIAIqDAuDxQIt0B5xFb6NuZ 7iVw+YgjGieMt/2ovNxxqW4tQos8FIlSNngh7SMwaOI29sxVz5U5z3arIz2doaHC+vtTGJzL7d Fs2ZKhzyAPItiM1q6ffRrXN8L6yZyZanPWfY2NUgiJ7vEdJHQ34Cz7RPPEGElbsBmP4loOnHFG SXqK8v9jr74LQs3LaAOIBCor
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
This is a fastpath on virtual vmentry/exit, and forcing guest_pat to be
spilled to the stack is bad. Performing the shift in a register is far more
efficient.
Drop the (IMO useless) log message. MSR_PAT only gets altered on boot, and a
bad value will be entirely evident in the ensuing #GP backtrace.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
---
xen/arch/x86/hvm/hvm.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index d233550ae47b..e3c9b3794544 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -299,13 +299,13 @@ void hvm_get_guest_pat(struct vcpu *v, u64 *guest_pat)
*guest_pat = v->arch.hvm.pat_cr;
}
-int hvm_set_guest_pat(struct vcpu *v, u64 guest_pat)
+int hvm_set_guest_pat(struct vcpu *v, uint64_t guest_pat)
{
- int i;
- uint8_t *value = (uint8_t *)&guest_pat;
+ unsigned int i;
+ uint64_t tmp;
- for ( i = 0; i < 8; i++ )
- switch ( value[i] )
+ for ( i = 0, tmp = guest_pat; i < 8; i++, tmp >>= 8 )
+ switch ( tmp & 0xff )
{
case PAT_TYPE_UC_MINUS:
case PAT_TYPE_UNCACHABLE:
@@ -313,10 +313,9 @@ int hvm_set_guest_pat(struct vcpu *v, u64 guest_pat)
case PAT_TYPE_WRCOMB:
case PAT_TYPE_WRPROT:
case PAT_TYPE_WRTHROUGH:
- break;
+ continue;
+
default:
- HVM_DBG_LOG(DBG_LEVEL_MSR, "invalid guest PAT: %"PRIx64"\n",
- guest_pat);
return 0;
}
--
2.11.0
|