aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2008-02-18 14:12:48 -0500
committerAvi Kivity <avi@qumranet.com>2008-04-27 04:53:22 -0400
commitddcb2885e2902ebfc422eccd763b02c5ee22d68b (patch)
tree22acf0af546e312713cfe9516e41fb51f27ba521 /arch
parent790c73f6289a204f858ffdcbe4a2b38e91657ec6 (diff)
KVM: x86 emulator: add ad_mask static inline
Replaces open-coded mask calculation in macros. Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
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) \