aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kvm/x86_emulate.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index 22900f70172b..f6f6544cf747 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -480,10 +480,15 @@ static u16 group2_table[] = {
480 (_type)_x; \ 480 (_type)_x; \
481}) 481})
482 482
483static inline unsigned long ad_mask(struct decode_cache *c)
484{
485 return (1UL << (c->ad_bytes << 3)) - 1;
486}
487
483/* Access/update address held in a register, based on addressing mode. */ 488/* Access/update address held in a register, based on addressing mode. */
484#define address_mask(reg) \ 489#define address_mask(reg) \
485 ((c->ad_bytes == sizeof(unsigned long)) ? \ 490 ((c->ad_bytes == sizeof(unsigned long)) ? \
486 (reg) : ((reg) & ((1UL << (c->ad_bytes << 3)) - 1))) 491 (reg) : ((reg) & ad_mask(c)))
487#define register_address(base, reg) \ 492#define register_address(base, reg) \
488 ((base) + address_mask(reg)) 493 ((base) + address_mask(reg))
489#define register_address_increment(reg, inc) \ 494#define register_address_increment(reg, inc) \
@@ -494,9 +499,9 @@ static u16 group2_table[] = {
494 (reg) += _inc; \ 499 (reg) += _inc; \
495 else \ 500 else \
496 (reg) = ((reg) & \ 501 (reg) = ((reg) & \
497 ~((1UL << (c->ad_bytes << 3)) - 1)) | \ 502 ~ad_mask(c)) | \
498 (((reg) + _inc) & \ 503 (((reg) + _inc) & \
499 ((1UL << (c->ad_bytes << 3)) - 1)); \ 504 ad_mask(c)); \
500 } while (0) 505 } while (0)
501 506
502#define JMP_REL(rel) \ 507#define JMP_REL(rel) \