LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/3] x86, kvm: add ad_mask static inline
@ 2008-02-18 19:12 Harvey Harrison
  2008-02-19  8:39 ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Harvey Harrison @ 2008-02-18 19:12 UTC (permalink / raw)
  To: Ingo Molnar, Avi Kivity; +Cc: H. Peter Anvin, Thomas Gleixner, LKML

Replaces open-coded mask calculation in macros.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 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 7958600..7460432 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -426,10 +426,15 @@ static u16 twobyte_table[256] = {
 	(_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)                            \
@@ -440,9 +445,9 @@ static u16 twobyte_table[256] = {
 			(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.1.1278.gc75be



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-02-19 15:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-18 19:12 [PATCH 1/3] x86, kvm: add ad_mask static inline Harvey Harrison
2008-02-19  8:39 ` Avi Kivity
2008-02-19 15:14   ` Harvey Harrison
2008-02-19 15:24     ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).