Discussion:
[Xen-changelog] [xen staging] x86/HVM: grow MMIO cache data size to 64 bytes
p***@xen.org
2018-11-19 08:44:04 UTC
Permalink
commit d95da91fb497d8583826f673f9325e73a7514277
Author: Jan Beulich <***@suse.com>
AuthorDate: Mon Nov 19 09:41:25 2018 +0100
Commit: Jan Beulich <***@suse.com>
CommitDate: Mon Nov 19 09:41:25 2018 +0100

x86/HVM: grow MMIO cache data size to 64 bytes

This is needed before enabling any AVX512 insns in the emulator. Change
the way alignment is enforced at the same time.

Add a check that the buffer won't actually overflow, and while at it
also convert the check for accesses to not cross page boundaries.

Signed-off-by: Jan Beulich <***@suse.com>
Reviewed-by: Paul Durrant <***@citrix.com>
Acked-by: Andrew Cooper <***@citrix.com>
---
xen/arch/x86/hvm/emulate.c | 13 ++++++++++++-
xen/include/asm-x86/hvm/vcpu.h | 5 ++---
2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 488ea5e956..2d02ef1521 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -876,7 +876,18 @@ static int hvmemul_phys_mmio_access(
int rc = X86EMUL_OKAY;

/* Accesses must fall within a page. */
- BUG_ON((gpa & ~PAGE_MASK) + size > PAGE_SIZE);
+ if ( (gpa & ~PAGE_MASK) + size > PAGE_SIZE )
+ {
+ ASSERT_UNREACHABLE();
+ return X86EMUL_UNHANDLEABLE;
+ }
+
+ /* Accesses must not overflow the cache's buffer. */
+ if ( size > sizeof(cache->buffer) )
+ {
+ ASSERT_UNREACHABLE();
+ return X86EMUL_UNHANDLEABLE;
+ }

/*
* hvmemul_do_io() cannot handle non-power-of-2 accesses or
diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h
index c663155b4b..39778f9e4e 100644
--- a/xen/include/asm-x86/hvm/vcpu.h
+++ b/xen/include/asm-x86/hvm/vcpu.h
@@ -42,15 +42,14 @@ struct hvm_vcpu_asid {
};

/*
- * We may read or write up to m256 as a number of device-model
+ * We may read or write up to m512 as a number of device-model
* transactions.
*/
struct hvm_mmio_cache {
unsigned long gla;
unsigned int size;
uint8_t dir;
- uint8_t pad[3]; /* make buffer[] long-aligned */
- uint8_t buffer[32];
+ uint8_t buffer[64] __aligned(sizeof(long));
};

struct hvm_vcpu_io {
--
generated by git-patchbot for /home/xen/git/xen.git#staging

Loading...