From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, aliguori@amazon.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH] hw/i386: Use unaligned store functions building acpi tables
Date: Wed, 12 Mar 2014 15:25:46 -0700 [thread overview]
Message-ID: <1394663146-24552-1-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1394480575-3698-2-git-send-email-mst@redhat.com>
Hosts that don't support native unaligned stores will SIGBUS
without additional help.
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
hw/i386/acpi-build.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index b1a7ebb..d636115 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -886,22 +886,24 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size)
{
- *ACPI_BUILD_PTR(start, size, acpi_pci32_start[0], uint32_t) =
- cpu_to_le32(pci->w32.begin);
+ /* Note that these pointers are unaligned, so we must use routines
+ that take care for unaligned stores on the host. */
- *ACPI_BUILD_PTR(start, size, acpi_pci32_end[0], uint32_t) =
- cpu_to_le32(pci->w32.end - 1);
+ stl_le_p(ACPI_BUILD_PTR(start, size, acpi_pci32_start[0], uint32_t),
+ pci->w32.begin);
+ stl_le_p(ACPI_BUILD_PTR(start, size, acpi_pci32_end[0], uint32_t),
+ pci->w32.end - 1);
if (pci->w64.end || pci->w64.begin) {
- *ACPI_BUILD_PTR(start, size, acpi_pci64_valid[0], uint8_t) = 1;
- *ACPI_BUILD_PTR(start, size, acpi_pci64_start[0], uint64_t) =
- cpu_to_le64(pci->w64.begin);
- *ACPI_BUILD_PTR(start, size, acpi_pci64_end[0], uint64_t) =
- cpu_to_le64(pci->w64.end - 1);
- *ACPI_BUILD_PTR(start, size, acpi_pci64_length[0], uint64_t) =
- cpu_to_le64(pci->w64.end - pci->w64.begin);
+ stb_p(ACPI_BUILD_PTR(start, size, acpi_pci64_valid[0], uint8_t), 1);
+ stq_le_p(ACPI_BUILD_PTR(start, size, acpi_pci64_start[0], uint64_t),
+ pci->w64.begin);
+ stq_le_p(ACPI_BUILD_PTR(start, size, acpi_pci64_end[0], uint64_t),
+ pci->w64.end - 1);
+ stq_le_p(ACPI_BUILD_PTR(start, size, acpi_pci64_length[0], uint64_t),
+ pci->w64.end - pci->w64.begin);
} else {
- *ACPI_BUILD_PTR(start, size, acpi_pci64_valid[0], uint8_t) = 0;
+ stb_p(ACPI_BUILD_PTR(start, size, acpi_pci64_valid[0], uint8_t), 0);
}
}
@@ -930,8 +932,7 @@ build_ssdt(GArray *table_data, GArray *linker,
patch_pci_windows(pci, ssdt_ptr, sizeof(ssdp_misc_aml));
- *(uint16_t *)(ssdt_ptr + *ssdt_isa_pest) =
- cpu_to_le16(misc->pvpanic_port);
+ stw_le_p(ssdt_ptr + *ssdt_isa_pest, misc->pvpanic_port);
{
GArray *sb_scope = build_alloc_array();
--
1.8.5.3
next prev parent reply other threads:[~2014-03-12 22:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-10 19:43 [Qemu-devel] [PATCH 1/2] bswap.h: export bswap_le Michael S. Tsirkin
2014-03-10 19:43 ` [Qemu-devel] [PATCH 2/2] acpi-build: don't access unaligned addresses Michael S. Tsirkin
2014-03-12 22:24 ` Richard Henderson
2014-03-12 22:25 ` Richard Henderson [this message]
2014-03-12 23:26 ` [Qemu-devel] [PATCH] hw/i386: Use unaligned store functions building acpi tables Peter Maydell
2014-03-13 13:30 ` Richard Henderson
2014-03-12 22:21 ` [Qemu-devel] [PATCH 1/2] bswap.h: export bswap_le Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1394663146-24552-1-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=aliguori@amazon.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).