[PATCH 34/40] KVM: x86 emulator: add ad_mask static inline
- From: Avi Kivity <avi@xxxxxxxxxxxx>
- Date: Mon, 31 Mar 2008 17:37:18 +0300
From: Harvey Harrison <harvey.harrison@xxxxxxxxx>
Replaces open-coded mask calculation in macros.
Signed-off-by: Harvey Harrison <harvey.harrison@xxxxxxxxx>
Signed-off-by: Avi Kivity <avi@xxxxxxxxxxxx>
---
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 22900f7..f6f6544 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) \
--
1.5.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- References:
- [PATCH 00/40] KVM updates for the 2.6.26 merge window (part I)
- From: Avi Kivity
- [PATCH 00/40] KVM updates for the 2.6.26 merge window (part I)
- Prev by Date: [PATCH 30/40] KVM: SVM: allocate the MSR permission map per VCPU
- Next by Date: [PATCH 35/40] KVM: x86 emulator: make register_address, address_mask static inlines
- Previous by thread: [PATCH 30/40] KVM: SVM: allocate the MSR permission map per VCPU
- Next by thread: [PATCH 35/40] KVM: x86 emulator: make register_address, address_mask static inlines
- Index(es):
Relevant Pages
- [PATCH 1/3] x86, kvm: add ad_mask static inline
... Replaces open-coded mask calculation in macros. ... More majordomo
info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/
... (Linux-Kernel) - Re: [PATCH 0/2] atl1: minor cleanup
... use dev_printk macros ... More majordomo info at http://vger.kernel.org/majordomo-info.html
... Please read the FAQ at http://www.tux.org/lkml/ ... (Linux-Kernel) - [PATCH] KEYS: fix macro
... Commit 664cceb0093b755739e56572b836a99104ee8a75 changed the ... The macros
that ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please
read the FAQ at http://www.tux.org/lkml/ ... (Linux-Kernel) - Re: [PATCH] [2/2] Remove NUMAQ support in io_32.h
... macros in io_32.h ... readable standard inlines. ... More majordomo
info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/
... (Linux-Kernel) - Re: [PATCH 16/16] fix handling of integer constant expressions
... While BUILD_BUG_ON and a few other macros in linux/kernel.h are currently ...
exported to user space, I would think that they should really be hidden ... More majordomo
info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/
... (Linux-Kernel)