[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86/HVM: add known_gla() emulation helper
commit 9f232721deaeb9f56eeffb555c4b7ecd62708667 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Tue Sep 11 11:03:14 2018 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Tue Sep 11 11:03:14 2018 +0200 x86/HVM: add known_gla() emulation helper ... as a central place to do respective checking for whether the translation for the linear address is available as well as usable. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Paul Durrant <paul.durrant@xxxxxxxxxx> --- xen/arch/x86/hvm/emulate.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 3b0c49853a..62e88723e4 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -1044,6 +1044,26 @@ static inline int hvmemul_linear_mmio_write( pfec, hvmemul_ctxt, translate); } +static bool known_gla(unsigned long addr, unsigned int bytes, uint32_t pfec) +{ + const struct hvm_vcpu_io *vio = ¤t->arch.hvm.hvm_io; + + if ( pfec & PFEC_write_access ) + { + if ( !vio->mmio_access.write_access ) + return false; + } + else if ( pfec & PFEC_insn_fetch ) + { + if ( !vio->mmio_access.insn_fetch ) + return false; + } + else if ( !vio->mmio_access.read_access ) + return false; + + return vio->mmio_gla == (addr & PAGE_MASK); +} + static int __hvmemul_read( enum x86_segment seg, unsigned long offset, @@ -1052,11 +1072,9 @@ static int __hvmemul_read( enum hvm_access_type access_type, struct hvm_emulate_ctxt *hvmemul_ctxt) { - struct vcpu *curr = current; pagefault_info_t pfinfo; unsigned long addr, reps = 1; uint32_t pfec = PFEC_page_present; - struct hvm_vcpu_io *vio = &curr->arch.hvm.hvm_io; int rc; if ( is_x86_system_segment(seg) ) @@ -1070,10 +1088,7 @@ static int __hvmemul_read( seg, offset, bytes, &reps, access_type, hvmemul_ctxt, &addr); if ( rc != X86EMUL_OKAY || !bytes ) return rc; - if ( ((access_type != hvm_access_insn_fetch - ? vio->mmio_access.read_access - : vio->mmio_access.insn_fetch)) && - (vio->mmio_gla == (addr & PAGE_MASK)) ) + if ( known_gla(addr, bytes, pfec) ) return hvmemul_linear_mmio_read(addr, bytes, p_data, pfec, hvmemul_ctxt, 1); rc = hvm_copy_from_guest_linear(p_data, addr, bytes, pfec, &pfinfo); @@ -1174,10 +1189,8 @@ static int hvmemul_write( { struct hvm_emulate_ctxt *hvmemul_ctxt = container_of(ctxt, struct hvm_emulate_ctxt, ctxt); - struct vcpu *curr = current; unsigned long addr, reps = 1; uint32_t pfec = PFEC_page_present | PFEC_write_access; - struct hvm_vcpu_io *vio = &curr->arch.hvm.hvm_io; int rc; void *mapping; @@ -1191,8 +1204,7 @@ static int hvmemul_write( if ( rc != X86EMUL_OKAY || !bytes ) return rc; - if ( vio->mmio_access.write_access && - (vio->mmio_gla == (addr & PAGE_MASK)) ) + if ( known_gla(addr, bytes, pfec) ) return hvmemul_linear_mmio_write(addr, bytes, p_data, pfec, hvmemul_ctxt, 1); mapping = hvmemul_map_linear_addr(addr, bytes, pfec, hvmemul_ctxt); @@ -1221,7 +1233,6 @@ static int hvmemul_rmw( container_of(ctxt, struct hvm_emulate_ctxt, ctxt); unsigned long addr, reps = 1; uint32_t pfec = PFEC_page_present | PFEC_write_access; - struct hvm_vcpu_io *vio = ¤t->arch.hvm.hvm_io; int rc; void *mapping; @@ -1247,8 +1258,7 @@ static int hvmemul_rmw( else { unsigned long data = 0; - bool known_gpfn = vio->mmio_access.write_access && - vio->mmio_gla == (addr & PAGE_MASK); + bool known_gpfn = known_gla(addr, bytes, pfec); if ( bytes > sizeof(data) ) return X86EMUL_UNHANDLEABLE; -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |