|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/HVM: convert hvm_virtual_to_linear_addr() to be remote-capable
commit dffe59c12444a97d9af82db6e6e4df7e2143c5f5
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Sep 29 11:56:18 2021 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Sep 29 11:56:18 2021 +0200
x86/HVM: convert hvm_virtual_to_linear_addr() to be remote-capable
While all present callers want to act on "current", stack dumping for
HVM vCPU-s will require the function to be able to act on a remote vCPU.
To avoid touching all present callers, convert the existing function to
an inline wrapper around the extend new one.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
xen/arch/x86/hvm/hvm.c | 20 ++++++++++++--------
xen/include/asm-x86/hvm/hvm.h | 17 ++++++++++++++++-
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 7b48a1b925..c8c86dd6a6 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2526,7 +2526,8 @@ int hvm_set_cr4(unsigned long value, bool may_defer)
return X86EMUL_OKAY;
}
-bool_t hvm_virtual_to_linear_addr(
+bool hvm_vcpu_virtual_to_linear(
+ struct vcpu *v,
enum x86_segment seg,
const struct segment_register *reg,
unsigned long offset,
@@ -2535,9 +2536,12 @@ bool_t hvm_virtual_to_linear_addr(
const struct segment_register *active_cs,
unsigned long *linear_addr)
{
- const struct vcpu *curr = current;
unsigned long addr = offset, last_byte;
- bool_t okay = 0;
+ const struct cpu_user_regs *regs = v == current ? guest_cpu_user_regs()
+ : &v->arch.user_regs;
+ bool okay = false;
+
+ ASSERT(v == current || !vcpu_runnable(v));
/*
* These checks are for a memory access through an active segment.
@@ -2547,7 +2551,7 @@ bool_t hvm_virtual_to_linear_addr(
*/
ASSERT(seg < x86_seg_none);
- if ( !(curr->arch.hvm.guest_cr[0] & X86_CR0_PE) )
+ if ( !(v->arch.hvm.guest_cr[0] & X86_CR0_PE) )
{
/*
* REAL MODE: Don't bother with segment access checks.
@@ -2555,7 +2559,7 @@ bool_t hvm_virtual_to_linear_addr(
*/
addr = (uint32_t)(addr + reg->base);
}
- else if ( (guest_cpu_user_regs()->eflags & X86_EFLAGS_VM) &&
+ else if ( (regs->eflags & X86_EFLAGS_VM) &&
is_x86_user_segment(seg) )
{
/* VM86 MODE: Fixed 64k limits on all user segments. */
@@ -2564,7 +2568,7 @@ bool_t hvm_virtual_to_linear_addr(
if ( max(offset, last_byte) >> 16 )
goto out;
}
- else if ( hvm_long_mode_active(curr) &&
+ else if ( hvm_long_mode_active(v) &&
(is_x86_system_segment(seg) || active_cs->l) )
{
/*
@@ -2636,12 +2640,12 @@ bool_t hvm_virtual_to_linear_addr(
else if ( last_byte > reg->limit )
goto out; /* last byte is beyond limit */
else if ( last_byte < offset &&
- curr->domain->arch.cpuid->x86_vendor == X86_VENDOR_AMD )
+ v->domain->arch.cpuid->x86_vendor == X86_VENDOR_AMD )
goto out; /* access wraps */
}
/* All checks ok. */
- okay = 1;
+ okay = true;
out:
/*
diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
index 7e842f2dc2..bd2cbb0e7b 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -314,7 +314,9 @@ enum hvm_access_type {
hvm_access_read,
hvm_access_write
};
-bool_t hvm_virtual_to_linear_addr(
+
+bool hvm_vcpu_virtual_to_linear(
+ struct vcpu *v,
enum x86_segment seg,
const struct segment_register *reg,
unsigned long offset,
@@ -323,6 +325,19 @@ bool_t hvm_virtual_to_linear_addr(
const struct segment_register *active_cs,
unsigned long *linear_addr);
+static inline bool hvm_virtual_to_linear_addr(
+ enum x86_segment seg,
+ const struct segment_register *reg,
+ unsigned long offset,
+ unsigned int bytes,
+ enum hvm_access_type access_type,
+ const struct segment_register *active_cs,
+ unsigned long *linear)
+{
+ return hvm_vcpu_virtual_to_linear(current, seg, reg, offset, bytes,
+ access_type, active_cs, linear);
+}
+
void *hvm_map_guest_frame_rw(unsigned long gfn, bool_t permanent,
bool_t *writable);
void *hvm_map_guest_frame_ro(unsigned long gfn, bool_t permanent);
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |