From 184b813e7b1fe2dc27e7657befc907b5aac3b619 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 29 Oct 2020 16:33:48 +0100 Subject: spapr: Drop dead code in spapr_reallocate_hpt() Sometimes QEMU needs to allocate the HPT in userspace, namely with TCG or PR KVM. This is performed with qemu_memalign() because of alignment requirements. Like glib's allocators, its behaviour is to abort on OOM instead of returning NULL. This could be changed to qemu_try_memalign(), but in the specific case of spapr_reallocate_hpt(), the outcome would be to terminate QEMU anyway since no HPT means no MMU for the guest. Drop the dead code instead. Signed-off-by: Greg Kurz Message-Id: <160398562892.32380.15006707861753544263.stgit@bahia.lan> Signed-off-by: David Gibson --- hw/ppc/spapr.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'hw') diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 2270751..12a012d 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1522,12 +1522,6 @@ int spapr_reallocate_hpt(SpaprMachineState *spapr, int shift, Error **errp) int i; spapr->htab = qemu_memalign(size, size); - if (!spapr->htab) { - error_setg_errno(errp, errno, - "Could not allocate HPT of order %d", shift); - return -ENOMEM; - } - memset(spapr->htab, 0, size); spapr->htab_shift = shift; -- cgit v1.1 From f29b959dc6871c9d8df781d1bedcfaebc76d5565 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 29 Oct 2020 16:33:56 +0100 Subject: spapr: Convert hpt_prepare_thread() to use qemu_try_memalign() HPT resizing is asynchronous: the guest first kicks off the creation of a new HPT, then it waits for that new HPT to be actually created and finally it asks the current HPT to be replaced by the new one. In the case of a userland allocated HPT, this currently relies on calling qemu_memalign() which aborts on OOM and never returns NULL. Since we seem to have path to report the failure to the guest with an H_NO_MEM return value, use qemu_try_memalign() instead of qemu_memalign(). Signed-off-by: Greg Kurz Message-Id: <160398563636.32380.1747166034877173994.stgit@bahia.lan> Signed-off-by: David Gibson --- hw/ppc/spapr_hcall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 6077401..1d8e8e6 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -360,7 +360,7 @@ static void *hpt_prepare_thread(void *opaque) SpaprPendingHpt *pending = opaque; size_t size = 1ULL << pending->shift; - pending->hpt = qemu_memalign(size, size); + pending->hpt = qemu_try_memalign(size, size); if (pending->hpt) { memset(pending->hpt, 0, size); pending->ret = H_SUCCESS; -- cgit v1.1