diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-02-18 11:12:48 -0800 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-04-27 11:53:22 +0300 |
commit | ddcb2885e2902ebfc422eccd763b02c5ee22d68b (patch) | |
tree | 22acf0af546e312713cfe9516e41fb51f27ba521 | |
parent | 790c73f6289a204f858ffdcbe4a2b38e91657ec6 (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>
-rw-r--r-- | arch/x86/kvm/x86_emulate.c | 11 |
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[] = { (_type)_x; \ }) +static inline unsigned long ad_mask(struct decode_cache *c) +{ + return (1UL << (c->ad_bytes << 3)) - 1; +} + /* Access/update address held in a register, based on addressing mode. */ #define address_mask(reg) \ ((c->ad_bytes == sizeof(unsigned long)) ? \ - (reg) : ((reg) & ((1UL << (c->ad_bytes << 3)) - 1))) + (reg) : ((reg) & ad_mask(c))) #define register_address(base, reg) \ ((base) + address_mask(reg)) #define register_address_increment(reg, inc) \ @@ -494,9 +499,9 @@ static u16 group2_table[] = { (reg) += _inc; \ else \ (reg) = ((reg) & \ - ~((1UL << (c->ad_bytes << 3)) - 1)) | \ + ~ad_mask(c)) | \ (((reg) + _inc) & \ - ((1UL << (c->ad_bytes << 3)) - 1)); \ + ad_mask(c)); \ } while (0) #define JMP_REL(rel) \ |