[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 47/58] optionrom: do not rely on compiler's bswap opt
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 47/58] optionrom: do not rely on compiler's bswap optimization |
Date: |
Tue, 13 Sep 2016 19:16:18 +0200 |
Recent compilers can detect and inline manually-written bswap code,
but GCC 4.2.1 (the last GPLv2 version) cannot and generates really
awful code. Depending on how the compiler is configured, it might
also not want to generate bswap because it was not in i386. Using
asm is fine because TCG knows about bswap and all processors with
virtualization extensions also do.
Reported-by: Peter Maydell <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
pc-bios/linuxboot_dma.bin | Bin 1536 -> 1536 bytes
pc-bios/optionrom/linuxboot_dma.c | 18 ++++--------------
2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/pc-bios/linuxboot_dma.bin b/pc-bios/linuxboot_dma.bin
index
238a195d3869995067f158d243d852778d38a736..218d3ab4a29bfb5ab7125ec7a4d29dad1860c673
100644
GIT binary patch
delta 339
zcmZqRY2cX<address@hidden)%0mw_QIIIZ(address@hidden;address@hidden)p8vn^O
z{?qAcoh~XIKr%#y2T1y;umDLJm9$+FtU&FZ4<`OnXBS9|PCJ}7VX^_Eq+#*@|Nqm|
zdR<fm(sr^i0F~?#2azwL!Q$O4Ae}&g^t5gtppq9Z|0h>5I!ZFabcw)paf5ZeoP33G
address@hidden|Ja#Es#jtB?z$$=!diyoG|q~F!jP<^&kI2&6k0R
mi-5&%g2lUqTvT|address@hidden>_jEn%58-ITQ
delta 431
zcmXwyy-Pw-7{<>{qpRJ}@<zvSJkji*5IDL;IYdRv<I?ETbQPyVTu2;RT8ftDT)NP3
z3|c~ph9rW>2)#oPZ9?Sj_1IY+UVhKVTXm|address@hidden;^g|K?zbJ)address@hidden)%
address@hidden;9Z$q}B-Z>JlP=hoQPpID~vBIc<{3Gh0E~VQP8$yK~wSk_R
address@hidden>C#XLxLl%WiS`iNEzKD~?1>_q7KFwI;Y&GR#3p?1wHg5bDp@(cf6Gc%O
zenF&h6{lGQOJfaxMq_?R0|6&MXOSY|$Edk%tz}QOOD)&5W_3$8E7r01{rkUZ8+S&#
z&xUiuZOxVD^nfFnpFArF8{vh?J0_pe`G(;+!(Gh}COZoS;UHL?3>8HV;ojxRR4itB
Ee=`xOo&W#<
diff --git a/pc-bios/optionrom/linuxboot_dma.c
b/pc-bios/optionrom/linuxboot_dma.c
index 7549797..4754282 100644
--- a/pc-bios/optionrom/linuxboot_dma.c
+++ b/pc-bios/optionrom/linuxboot_dma.c
@@ -122,24 +122,14 @@ static inline void writel_es(uint16_t offset, uint32_t
val)
static inline uint32_t bswap32(uint32_t x)
{
- return
- ((x & 0x000000ffU) << 24) |
- ((x & 0x0000ff00U) << 8) |
- ((x & 0x00ff0000U) >> 8) |
- ((x & 0xff000000U) >> 24);
+ asm("bswapl %0" : "=r" (x) : "0" (x));
+ return x;
}
static inline uint64_t bswap64(uint64_t x)
{
- return
- ((x & 0x00000000000000ffULL) << 56) |
- ((x & 0x000000000000ff00ULL) << 40) |
- ((x & 0x0000000000ff0000ULL) << 24) |
- ((x & 0x00000000ff000000ULL) << 8) |
- ((x & 0x000000ff00000000ULL) >> 8) |
- ((x & 0x0000ff0000000000ULL) >> 24) |
- ((x & 0x00ff000000000000ULL) >> 40) |
- ((x & 0xff00000000000000ULL) >> 56);
+ asm("bswapl %%eax; bswapl %%edx; xchg %%eax, %%edx" : "=A" (x) : "0" (x));
+ return x;
}
static inline uint64_t cpu_to_be64(uint64_t x)
--
1.8.3.1
- [Qemu-devel] [PULL 37/58] ipmi: check return of qemu_chr_fe_write() for errors, (continued)
- [Qemu-devel] [PULL 37/58] ipmi: check return of qemu_chr_fe_write() for errors, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 40/58] char: convert qemu_chr_fe_write to qemu_chr_fe_write_all, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 39/58] hw: replace most use of qemu_chr_fe_write with qemu_chr_fe_write_all, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 42/58] i8257: Make device "i8257" unavailable with -device, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 43/58] kvm-all: drop kvm_setup_guest_memory, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 41/58] Revert "megasas: remove useless check for cmd->frame", Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 36/58] default-configs: remove CONFIG_PIIX_PCI, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 45/58] atomics: Use __atomic_*_n() variant primitives, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 44/58] atomics: Remove redundant barrier()'s, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 46/58] checkpatch: Fix whitespace checks for documentation code blocks, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 47/58] optionrom: do not rely on compiler's bswap optimization,
Paolo Bonzini <=
- [Qemu-devel] [PULL 51/58] cutils: Remove SPLAT macro, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 54/58] cutils: Remove aarch64 buffer zero checking, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 49/58] ppc: do not redefine CPUPPCState, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 53/58] cutils: Rearrange buffer_is_zero acceleration, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 50/58] cutils: Move buffer_is_zero and subroutines to a new file, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 52/58] cutils: Export only buffer_is_zero, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 56/58] cutils: Add test for buffer_is_zero, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 58/58] cutils: Add generic prefetch, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 55/58] cutils: Remove ppc buffer zero checking, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 57/58] cutils: Add SSE4 version, Paolo Bonzini, 2016/09/13