From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586895070; cv=none; d=zohomail.com; s=zohoarc; b=UqqsnW48ovx/NBf2WMwhkPXvjKAEjyFoxnBs3ET6BN2wEih+vqtPtxfCdmNWW1k6j4tbjZXQ8zUfImOT9FK/qNq8FkdCyeUudqy8tK+Ubv8BVeQYdaoOtRacr/Gjai1ioPmZxNK2O3UEkxNCsKgYuhueiEG8F97kWY+hBb/xsTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586895070; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TTjAvCpLg+iizZbAaS2I0hTe9cFREBgQw4ZC2om1lsY=; b=CRvwIc8WrS3tAp7E83J2yLNZs0UtVq667Ygsum5yaZDggheSsOwUpPPrL0zuMOxuaS7ETxRHdh7i1QxFLGCPEcjV2nkLpLyN+aU+qlzntrW3uNtnA2UW5fd9e2iujhebrN5GM1eElqqY6NXud4t/dnigSaNzwA6DnAquz7hrDaQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586895070659902.9576168522583; Tue, 14 Apr 2020 13:11:10 -0700 (PDT) Received: from localhost ([::1]:38462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORtl-00063h-CU for importer@patchew.org; Tue, 14 Apr 2020 16:11:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44457) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpR-0005wX-Kc for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpO-0005uI-OJ for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:41 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:55539) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpO-0005tx-De for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:38 -0400 Received: by mail-wm1-x332.google.com with SMTP id e26so14519014wmk.5 for ; Tue, 14 Apr 2020 13:06:38 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k8sm18465750wrm.52.2020.04.14.13.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:32 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 87DB21FF87; Tue, 14 Apr 2020 21:06:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TTjAvCpLg+iizZbAaS2I0hTe9cFREBgQw4ZC2om1lsY=; b=iUiaVCoCUvH7jDIizaBqMbcIjps7k5eqfhxTzJpuBEy5sKbiWF1IA0g2u4wfaZ3tEe 0PsZkEvjj+P9N7b7tsV7LF6f7jwSJtzEp8FtJuAdaFOvzmJM6Zv8IeU6BwKaQvV0OnqM Pkniyxgu2vhsLV7FfBAcPwghj5tckuyOhhO5Z86CONclnxOwhL6dXGf5RlRPBQfIJOXI 6NcX2wkNT/x0gdsSTXvetkOSu6Z52ZFxtp5af9fkYhxyqcf7LbRmSB6k0DMec4vgwUsC qKP/roW0C6M2J0xBoZ4HLr8IBp0blz41kHoeN8rVEACG+O97QBhtVJCaLfNV566pOXyC cz8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TTjAvCpLg+iizZbAaS2I0hTe9cFREBgQw4ZC2om1lsY=; b=IZPSA/Pa8evmHCHo8tKOG5RG0Z9ViXobXhnFwQos05RcKUNHYdq6xQ/W7aaCgSX0Ek ewGIMD0PFrJf8gixtjrXcfPA7anGjaAtjZSl+XcRZbOucijEcHpkIwtVMiBvcwTRIX1T E+PVc+CSSM39dWxFVC/z3RS89U0q40XAV8wfKWeP+XWjoZRqaiF8U80MF2VDeuPgKSHs 9s0tvCN2CalSuG9qTrnixTTE9xwP+zqDcLfEhcUC27NxRXdO4JYkC5E1v40uPoSv1/vV Eh4pU2NJS/1kkLP/RYfi9FGWOJbe+EstMSdKuDyZ7nBTRl1M/h/fNZ0HUtPOyv34rpOB K/4w== X-Gm-Message-State: AGi0Pub7UNzVEoTEoB+Mm9qvfYK//WcAtq5tJuas4oKK5+mjgRSjp3Tt A5IKI4CZxHBBPSx4k209CceFuUDXbdI= X-Google-Smtp-Source: APiQypI6o2ezesbEXVBZRf8R43DBszf2g9lK6Z36F5QAECLxq5NXPQZoGDSfhwusMk7Rwj946AsF3w== X-Received: by 2002:a7b:c3c5:: with SMTP id t5mr1412623wmj.80.1586894796837; Tue, 14 Apr 2020 13:06:36 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 01/17] linux-user: completely re-write init_guest_space Date: Tue, 14 Apr 2020 21:06:15 +0100 Message-Id: <20200414200631.12799-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) First we ensure all guest space initialisation logic comes through probe_guest_base once we understand the nature of the binary we are loading. The convoluted init_guest_space routine is removed and replaced with a number of pgb_* helpers which are called depending on what requirements we have when loading the binary. We first try to do what is requested by the host. Failing that we try and satisfy the guest requested base address. If all those options fail we fall back to finding a space in the memory map using our recently written read_self_maps() helper. There are some additional complications we try and take into account when looking for holes in the address space. We try not to go directly after the system brk() space so there is space for a little growth. We also don't want to have to use negative offsets which would result in slightly less efficient code on x86 when it's unable to use the segment offset register. Less mind-binding gotos and hopefully clearer logic throughout. Signed-off-by: Alex Benn=C3=A9e --- v3 - include rth updates that - split probe_guest_base into multiple functions - more heuristics on gap finding v4 - whitespace fix --- linux-user/qemu.h | 31 ++- linux-user/elfload.c | 503 +++++++++++++++++++++--------------------- linux-user/flatload.c | 6 + linux-user/main.c | 23 +- 4 files changed, 277 insertions(+), 286 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 792c74290f8..ce902f5132a 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -219,18 +219,27 @@ void init_qemu_uname_release(void); void fork_start(void); void fork_end(int child); =20 -/* Creates the initial guest address space in the host memory space using - * the given host start address hint and size. The guest_start parameter - * specifies the start address of the guest space. guest_base will be the - * difference between the host start address computed by this function and - * guest_start. If fixed is specified, then the mapped address space must - * start at host_start. The real start address of the mapped memory space= is - * returned or -1 if there was an error. +/** + * probe_guest_base: + * @image_name: the executable being loaded + * @loaddr: the lowest fixed address in the executable + * @hiaddr: the highest fixed address in the executable + * + * Creates the initial guest address space in the host memory space. + * + * If @loaddr =3D=3D 0, then no address in the executable is fixed, + * i.e. it is fully relocatable. In that case @hiaddr is the size + * of the executable. + * + * This function will not return if a valid value for guest_base + * cannot be chosen. On return, the executable loader can expect + * + * target_mmap(loaddr, hiaddr - loaddr, ...) + * + * to succeed. */ -unsigned long init_guest_space(unsigned long host_start, - unsigned long host_size, - unsigned long guest_start, - bool fixed); +void probe_guest_base(const char *image_name, + abi_ulong loaddr, abi_ulong hiaddr); =20 #include "qemu/log.h" =20 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 619c054cc48..01a9323a637 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -11,6 +11,7 @@ #include "qemu/queue.h" #include "qemu/guest-random.h" #include "qemu/units.h" +#include "qemu/selfmap.h" =20 #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -382,68 +383,30 @@ enum { =20 /* The commpage only exists for 32 bit kernels */ =20 -/* Return 1 if the proposed guest space is suitable for the guest. - * Return 0 if the proposed guest space isn't suitable, but another - * address space should be tried. - * Return -1 if there is no way the proposed guest space can be - * valid regardless of the base. - * The guest code may leave a page mapped and populate it if the - * address is suitable. - */ -static int init_guest_commpage(unsigned long guest_base, - unsigned long guest_size) -{ - unsigned long real_start, test_page_addr; - - /* We need to check that we can force a fault on access to the - * commpage at 0xffff0fxx - */ - test_page_addr =3D guest_base + (0xffff0f00 & qemu_host_page_mask); - - /* If the commpage lies within the already allocated guest space, - * then there is no way we can allocate it. - * - * You may be thinking that that this check is redundant because - * we already validated the guest size against MAX_RESERVED_VA; - * but if qemu_host_page_mask is unusually large, then - * test_page_addr may be lower. - */ - if (test_page_addr >=3D guest_base - && test_page_addr < (guest_base + guest_size)) { - return -1; - } +#define ARM_COMMPAGE (intptr_t)0xffff0f00u =20 - /* Note it needs to be writeable to let us initialise it */ - real_start =3D (unsigned long) - mmap((void *)test_page_addr, qemu_host_page_size, - PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); +static bool init_guest_commpage(void) +{ + void *want =3D g2h(ARM_COMMPAGE & -qemu_host_page_size); + void *addr =3D mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); =20 - /* If we can't map it then try another address */ - if (real_start =3D=3D -1ul) { - return 0; + if (addr =3D=3D MAP_FAILED) { + perror("Allocating guest commpage"); + exit(EXIT_FAILURE); } - - if (real_start !=3D test_page_addr) { - /* OS didn't put the page where we asked - unmap and reject */ - munmap((void *)real_start, qemu_host_page_size); - return 0; + if (addr !=3D want) { + return false; } =20 - /* Leave the page mapped - * Populate it (mmap should have left it all 0'd) - */ - - /* Kernel helper versions */ - __put_user(5, (uint32_t *)g2h(0xffff0ffcul)); + /* Set kernel helper versions; rest of page is 0. */ + __put_user(5, (uint32_t *)g2h(0xffff0ffcu)); =20 - /* Now it's populated make it RO */ - if (mprotect((void *)test_page_addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, qemu_host_page_size, PROT_READ)) { perror("Protecting guest commpage"); - exit(-1); + exit(EXIT_FAILURE); } - - return 1; /* All good */ + return true; } =20 #define ELF_HWCAP get_elf_hwcap() @@ -2075,239 +2038,267 @@ static abi_ulong create_elf_tables(abi_ulong p, i= nt argc, int envc, return sp; } =20 -unsigned long init_guest_space(unsigned long host_start, - unsigned long host_size, - unsigned long guest_start, - bool fixed) -{ - /* In order to use host shmat, we must be able to honor SHMLBA. */ - unsigned long align =3D MAX(SHMLBA, qemu_host_page_size); - unsigned long current_start, aligned_start; - int flags; - - assert(host_start || host_size); - - /* If just a starting address is given, then just verify that - * address. */ - if (host_start && !host_size) { -#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) - if (init_guest_commpage(host_start, host_size) !=3D 1) { - return (unsigned long)-1; - } +#ifndef ARM_COMMPAGE +#define ARM_COMMPAGE 0 +#define init_guest_commpage() true #endif - return host_start; - } =20 - /* Setup the initial flags and start address. */ - current_start =3D host_start & -align; - flags =3D MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE; - if (fixed) { - flags |=3D MAP_FIXED; - } +static void pgb_fail_in_use(const char *image_name) +{ + error_report("%s: requires virtual address space that is in use " + "(omit the -B option or choose a different value)", + image_name); + exit(EXIT_FAILURE); +} =20 - /* Otherwise, a non-zero size region of memory needs to be mapped - * and validated. */ +static void pgb_have_guest_base(const char *image_name, abi_ulong guest_lo= addr, + abi_ulong guest_hiaddr, long align) +{ + const int flags =3D MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE; + void *addr, *test; =20 -#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) - /* On 32-bit ARM, we need to map not just the usable memory, but - * also the commpage. Try to find a suitable place by allocating - * a big chunk for all of it. If host_start, then the naive - * strategy probably does good enough. - */ - if (!host_start) { - unsigned long guest_full_size, host_full_size, real_start; - - guest_full_size =3D - (0xffff0f00 & qemu_host_page_mask) + qemu_host_page_size; - host_full_size =3D guest_full_size - guest_start; - real_start =3D (unsigned long) - mmap(NULL, host_full_size, PROT_NONE, flags, -1, 0); - if (real_start =3D=3D (unsigned long)-1) { - if (host_size < host_full_size - qemu_host_page_size) { - /* We failed to map a continous segment, but we're - * allowed to have a gap between the usable memory and - * the commpage where other things can be mapped. - * This sparseness gives us more flexibility to find - * an address range. - */ - goto naive; - } - return (unsigned long)-1; + if (!QEMU_IS_ALIGNED(guest_base, align)) { + fprintf(stderr, "Requested guest base 0x%lx does not satisfy " + "host minimum alignment (0x%lx)\n", + guest_base, align); + exit(EXIT_FAILURE); + } + + /* Sanity check the guest binary. */ + if (reserved_va) { + if (guest_hiaddr > reserved_va) { + error_report("%s: requires more than reserved virtual " + "address space (0x%" PRIx64 " > 0x%lx)", + image_name, (uint64_t)guest_hiaddr, reserved_va); + exit(EXIT_FAILURE); } - munmap((void *)real_start, host_full_size); - if (real_start & (align - 1)) { - /* The same thing again, but with extra - * so that we can shift around alignment. - */ - unsigned long real_size =3D host_full_size + qemu_host_page_si= ze; - real_start =3D (unsigned long) - mmap(NULL, real_size, PROT_NONE, flags, -1, 0); - if (real_start =3D=3D (unsigned long)-1) { - if (host_size < host_full_size - qemu_host_page_size) { - goto naive; - } - return (unsigned long)-1; - } - munmap((void *)real_start, real_size); - real_start =3D ROUND_UP(real_start, align); + } else { + if ((guest_hiaddr - guest_base) > ~(uintptr_t)0) { + error_report("%s: requires more virtual address space " + "than the host can provide (0x%" PRIx64 ")", + image_name, (uint64_t)guest_hiaddr - guest_base); + exit(EXIT_FAILURE); } - current_start =3D real_start; } - naive: -#endif =20 - while (1) { - unsigned long real_start, real_size, aligned_size; - aligned_size =3D real_size =3D host_size; + /* + * Expand the allocation to the entire reserved_va. + * Exclude the mmap_min_addr hole. + */ + if (reserved_va) { + guest_loaddr =3D (guest_base >=3D mmap_min_addr ? 0 + : mmap_min_addr - guest_base); + guest_hiaddr =3D reserved_va; + } =20 - /* Do not use mmap_find_vma here because that is limited to the - * guest address space. We are going to make the - * guest address space fit whatever we're given. - */ - real_start =3D (unsigned long) - mmap((void *)current_start, host_size, PROT_NONE, flags, -1, 0= ); - if (real_start =3D=3D (unsigned long)-1) { - return (unsigned long)-1; - } + /* Reserve the address space for the binary, or reserved_va. */ + test =3D g2h(guest_loaddr); + addr =3D mmap(test, guest_hiaddr - guest_loaddr, PROT_NONE, flags, -1,= 0); + if (test !=3D addr) { + pgb_fail_in_use(image_name); + } +} =20 - /* Check to see if the address is valid. */ - if (host_start && real_start !=3D current_start) { - qemu_log_mask(CPU_LOG_PAGE, "invalid %lx && %lx !=3D %lx\n", - host_start, real_start, current_start); - goto try_again; +/* Return value for guest_base, or -1 if no hole found. */ +static uintptr_t pgb_find_hole(uintptr_t guest_loaddr, uintptr_t guest_siz= e, + long align) +{ + GSList *maps, *iter; + uintptr_t this_start, this_end, next_start, brk; + intptr_t ret =3D -1; + + assert(QEMU_IS_ALIGNED(guest_loaddr, align)); + + maps =3D read_self_maps(); + + /* Read brk after we've read the maps, which will malloc. */ + brk =3D (uintptr_t)sbrk(0); + + /* The first hole is before the first map entry. */ + this_start =3D mmap_min_addr; + + for (iter =3D maps; iter; + this_start =3D next_start, iter =3D g_slist_next(iter)) { + uintptr_t align_start, hole_size; + + this_end =3D ((MapInfo *)iter->data)->start; + next_start =3D ((MapInfo *)iter->data)->end; + align_start =3D ROUND_UP(this_start, align); + + /* Skip holes that are too small. */ + if (align_start >=3D this_end) { + continue; + } + hole_size =3D this_end - align_start; + if (hole_size < guest_size) { + continue; } =20 - /* Ensure the address is properly aligned. */ - if (real_start & (align - 1)) { - /* Ideally, we adjust like - * - * pages: [ ][ ][ ][ ][ ] - * old: [ real ] - * [ aligned ] - * new: [ real ] - * [ aligned ] - * - * But if there is something else mapped right after it, - * then obviously it won't have room to grow, and the - * kernel will put the new larger real someplace else with - * unknown alignment (if we made it to here, then - * fixed=3Dfalse). Which is why we grow real by a full page - * size, instead of by part of one; so that even if we get - * moved, we can still guarantee alignment. But this does - * mean that there is a padding of < 1 page both before - * and after the aligned range; the "after" could could - * cause problems for ARM emulation where it could butt in - * to where we need to put the commpage. - */ - munmap((void *)real_start, host_size); - real_size =3D aligned_size + align; - real_start =3D (unsigned long) - mmap((void *)real_start, real_size, PROT_NONE, flags, -1, = 0); - if (real_start =3D=3D (unsigned long)-1) { - return (unsigned long)-1; + /* If this hole contains brk, give ourselves some room to grow. */ + if (this_start <=3D brk && brk < this_end) { + hole_size -=3D guest_size; + if (sizeof(uintptr_t) =3D=3D 8 && hole_size >=3D 1 * GiB) { + align_start +=3D 1 * GiB; + } else if (hole_size >=3D 16 * MiB) { + align_start +=3D 16 * MiB; + } else { + align_start =3D (this_end - guest_size) & -align; + if (align_start < this_start) { + continue; + } } - aligned_start =3D ROUND_UP(real_start, align); - } else { - aligned_start =3D real_start; } =20 -#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) - /* On 32-bit ARM, we need to also be able to map the commpage. */ - int valid =3D init_guest_commpage(aligned_start - guest_start, - aligned_size + guest_start); - if (valid =3D=3D -1) { - munmap((void *)real_start, real_size); - return (unsigned long)-1; - } else if (valid =3D=3D 0) { - goto try_again; + /* Record the lowest successful match. */ + if (ret < 0) { + ret =3D align_start - guest_loaddr; } -#endif - - /* If nothing has said `return -1` or `goto try_again` yet, - * then the address we have is good. - */ - break; - - try_again: - /* That address didn't work. Unmap and try a different one. - * The address the host picked because is typically right at - * the top of the host address space and leaves the guest with - * no usable address space. Resort to a linear search. We - * already compensated for mmap_min_addr, so this should not - * happen often. Probably means we got unlucky and host - * address space randomization put a shared library somewhere - * inconvenient. - * - * This is probably a good strategy if host_start, but is - * probably a bad strategy if not, which means we got here - * because of trouble with ARM commpage setup. - */ - if (munmap((void *)real_start, real_size) !=3D 0) { - error_report("%s: failed to unmap %lx:%lx (%s)", __func__, - real_start, real_size, strerror(errno)); - abort(); + /* If this hole contains the identity map, select it. */ + if (align_start <=3D guest_loaddr && + guest_loaddr + guest_size <=3D this_end) { + ret =3D 0; } - current_start +=3D align; - if (host_start =3D=3D current_start) { - /* Theoretically possible if host doesn't have any suitably - * aligned areas. Normally the first mmap will fail. - */ - return (unsigned long)-1; + /* If this hole ends above the identity map, stop looking. */ + if (this_end >=3D guest_loaddr) { + break; } } + free_self_maps(maps); =20 - qemu_log_mask(CPU_LOG_PAGE, "Reserved 0x%lx bytes of guest address spa= ce\n", host_size); - - return aligned_start; + return ret; } =20 -static void probe_guest_base(const char *image_name, - abi_ulong loaddr, abi_ulong hiaddr) +static void pgb_static(const char *image_name, abi_ulong orig_loaddr, + abi_ulong orig_hiaddr, long align) { - /* Probe for a suitable guest base address, if the user has not set - * it explicitly, and set guest_base appropriately. - * In case of error we will print a suitable message and exit. - */ - const char *errmsg; - if (!have_guest_base && !reserved_va) { - unsigned long host_start, real_start, host_size; + uintptr_t loaddr =3D orig_loaddr; + uintptr_t hiaddr =3D orig_hiaddr; + uintptr_t addr; =20 - /* Round addresses to page boundaries. */ - loaddr &=3D qemu_host_page_mask; - hiaddr =3D HOST_PAGE_ALIGN(hiaddr); + if (hiaddr !=3D orig_hiaddr) { + error_report("%s: requires virtual address space that the " + "host cannot provide (0x%" PRIx64 ")", + image_name, (uint64_t)orig_hiaddr); + exit(EXIT_FAILURE); + } =20 - if (loaddr < mmap_min_addr) { - host_start =3D HOST_PAGE_ALIGN(mmap_min_addr); + loaddr &=3D -align; + if (ARM_COMMPAGE) { + /* + * Extend the allocation to include the commpage. + * For a 64-bit host, this is just 4GiB; for a 32-bit host, + * the address arithmetic will wrap around, but the difference + * will produce the correct allocation size. + */ + if (sizeof(uintptr_t) =3D=3D 8 || loaddr >=3D 0x80000000u) { + hiaddr =3D (uintptr_t)4 << 30; } else { - host_start =3D loaddr; - if (host_start !=3D loaddr) { - errmsg =3D "Address overflow loading ELF binary"; - goto exit_errmsg; - } + loaddr =3D ARM_COMMPAGE & -align; } - host_size =3D hiaddr - loaddr; + } =20 - /* Setup the initial guest memory space with ranges gleaned from - * the ELF image that is being loaded. + addr =3D pgb_find_hole(loaddr, hiaddr - loaddr, align); + if (addr =3D=3D -1) { + /* + * If ARM_COMMPAGE, there *might* be a non-consecutive allocation + * that can satisfy both. But as the normal arm32 link base addre= ss + * is ~32k, and we extend down to include the commpage, making the + * overhead only ~96k, this is unlikely. */ - real_start =3D init_guest_space(host_start, host_size, loaddr, fal= se); - if (real_start =3D=3D (unsigned long)-1) { - errmsg =3D "Unable to find space for application"; - goto exit_errmsg; - } - guest_base =3D real_start - loaddr; + error_report("%s: Unable to allocate %#zx bytes of " + "virtual address space", image_name, + (size_t)(hiaddr - loaddr)); + exit(EXIT_FAILURE); + } + + guest_base =3D addr; +} + +static void pgb_dynamic(const char *image_name, long align) +{ + /* + * The executable is dynamic and does not require a fixed address. + * All we need is a commpage that satisfies align. + * If we do not need a commpage, leave guest_base =3D=3D 0. + */ + if (ARM_COMMPAGE) { + uintptr_t addr, commpage; =20 - qemu_log_mask(CPU_LOG_PAGE, "Relocating guest address space from 0= x" - TARGET_ABI_FMT_lx " to 0x%lx\n", - loaddr, real_start); + /* 64-bit hosts should have used reserved_va. */ + assert(sizeof(uintptr_t) =3D=3D 4); + + /* + * By putting the commpage at the first hole, that puts guest_base + * just above that, and maximises the positive guest addresses. + */ + commpage =3D ARM_COMMPAGE & -align; + addr =3D pgb_find_hole(commpage, -commpage, align); + assert(addr !=3D -1); + guest_base =3D addr; } - return; +} =20 -exit_errmsg: - fprintf(stderr, "%s: %s\n", image_name, errmsg); - exit(-1); +static void pgb_reserved_va(const char *image_name, abi_ulong guest_loaddr, + abi_ulong guest_hiaddr, long align) +{ + const int flags =3D MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE; + void *addr, *test; + + if (guest_hiaddr > reserved_va) { + error_report("%s: requires more than reserved virtual " + "address space (0x%" PRIx64 " > 0x%lx)", + image_name, (uint64_t)guest_hiaddr, reserved_va); + exit(EXIT_FAILURE); + } + + /* Widen the "image" to the entire reserved address space. */ + pgb_static(image_name, 0, reserved_va, align); + + /* Reserve the memory on the host. */ + assert(guest_base !=3D 0); + test =3D g2h(0); + addr =3D mmap(test, reserved_va, PROT_NONE, flags, -1, 0); + if (addr =3D=3D MAP_FAILED) { + error_report("Unable to reserve 0x%lx bytes of virtual address " + "space for use as guest address space (check your " + "virtual memory ulimit setting or reserve less " + "using -R option)", reserved_va); + exit(EXIT_FAILURE); + } + assert(addr =3D=3D test); } =20 +void probe_guest_base(const char *image_name, abi_ulong guest_loaddr, + abi_ulong guest_hiaddr) +{ + /* In order to use host shmat, we must be able to honor SHMLBA. */ + uintptr_t align =3D MAX(SHMLBA, qemu_host_page_size); + + if (have_guest_base) { + pgb_have_guest_base(image_name, guest_loaddr, guest_hiaddr, align); + } else if (reserved_va) { + pgb_reserved_va(image_name, guest_loaddr, guest_hiaddr, align); + } else if (guest_loaddr) { + pgb_static(image_name, guest_loaddr, guest_hiaddr, align); + } else { + pgb_dynamic(image_name, align); + } + + /* Reserve and initialize the commpage. */ + if (!init_guest_commpage()) { + /* + * With have_guest_base, the user has selected the address and + * we are trying to work with that. Otherwise, we have selected + * free space and init_guest_commpage must succeeded. + */ + assert(have_guest_base); + pgb_fail_in_use(image_name); + } + + assert(QEMU_IS_ALIGNED(guest_base, align)); + qemu_log_mask(CPU_LOG_PAGE, "Locating guest address space " + "@ 0x%" PRIx64 "\n", (uint64_t)guest_base); +} =20 /* Load an ELF image into the address space. =20 @@ -2399,6 +2390,12 @@ static void load_elf_image(const char *image_name, i= nt image_fd, * MMAP_MIN_ADDR or the QEMU application itself. */ probe_guest_base(image_name, loaddr, hiaddr); + } else { + /* + * The binary is dynamic, but we still need to + * select guest_base. In this case we pass a size. + */ + probe_guest_base(image_name, 0, hiaddr - loaddr); } } =20 diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 66901f39cc5..8fb448f0bf0 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -441,6 +441,12 @@ static int load_flat_file(struct linux_binprm * bprm, indx_len =3D MAX_SHARED_LIBS * sizeof(abi_ulong); indx_len =3D (indx_len + 15) & ~(abi_ulong)15; =20 + /* + * Alloate the address space. + */ + probe_guest_base(bprm->filename, 0, + text_len + data_len + extra + indx_len); + /* * there are a couple of cases here, the separate code/data * case, and then the fully copied to RAM case which lumps diff --git a/linux-user/main.c b/linux-user/main.c index 22578b16336..1d20a83d4e8 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -24,6 +24,7 @@ #include "qemu-version.h" #include #include +#include =20 #include "qapi/error.h" #include "qemu.h" @@ -747,28 +748,6 @@ int main(int argc, char **argv, char **envp) target_environ =3D envlist_to_environ(envlist, NULL); envlist_free(envlist); =20 - /* - * Now that page sizes are configured in tcg_exec_init() we can do - * proper page alignment for guest_base. - */ - guest_base =3D HOST_PAGE_ALIGN(guest_base); - - if (reserved_va || have_guest_base) { - guest_base =3D init_guest_space(guest_base, reserved_va, 0, - have_guest_base); - if (guest_base =3D=3D (unsigned long)-1) { - fprintf(stderr, "Unable to reserve 0x%lx bytes of virtual addr= ess " - "space for use as guest address space (check your virt= ual " - "memory ulimit setting or reserve less using -R option= )\n", - reserved_va); - exit(EXIT_FAILURE); - } - - if (reserved_va) { - mmap_next_start =3D reserved_va; - } - } - /* * Read in mmap_min_addr kernel parameter. This value is used * When loading the ELF image to determine whether guest_base --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586894879; cv=none; d=zohomail.com; s=zohoarc; b=Pc6ZN3z7hxZrgvALtixqST4THgVr7hRXzi0KeGbnekzIPwwI/GmeB3tfr69tkZQ3+RkgrEjWlqHPbm/XY8ScOzKONyvwDZksJqfp3rmRKNWvYO12sRdN/qDln4CvjTPkH2Q+he5QAz2UEtf/J7QFdMr8Irr/+qGFwACOKfptWxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586894879; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LyYH1vUOROUp+ALOi+AoU+6fL4aHHF4lo5SZlCQc25A=; b=TryXO+3eDCkFlf+6aks9LYuo14/EZegd1N7pGpGPLB9VYu3q8XVjse/qZNjgt+Z+4n/S/JEl6l3UVHSMjI2UDEf42HLi61+mWMJCLsJy+bIj7mrzIo6Sbd5IymSWgaWro6DKFgELh1o3sHD2nnhPQW8Wm4JvrE/rwV2STkwRfsw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586894878990838.0992859317496; Tue, 14 Apr 2020 13:07:58 -0700 (PDT) Received: from localhost ([::1]:38344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORqf-0007Rw-5c for importer@patchew.org; Tue, 14 Apr 2020 16:07:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44422) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpN-0005t7-Ft for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpM-0005tB-5K for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:37 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:53853) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpL-0005si-RP for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:36 -0400 Received: by mail-wm1-x341.google.com with SMTP id d77so14502776wmd.3 for ; Tue, 14 Apr 2020 13:06:35 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u30sm22636wru.13.2020.04.14.13.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:32 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AE2271FF8C; Tue, 14 Apr 2020 21:06:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LyYH1vUOROUp+ALOi+AoU+6fL4aHHF4lo5SZlCQc25A=; b=IvmSZCaf0yjtZb0gsBQFlbhTvILOEfY9/Da4cG8YJArjhfh8PFu+VvvGPNwWFmXngu nUAqz6JWGDzYetx0BdIs/hktD5qPK7yIJAPWw7Ym83EBvpgOBGH38W8400kKl46oFxud eJYdz5OGnaPSNiRcwtOVhH4VRa60dvbzommM1bJeEDfyfu7IMSTBmNKl+R0NSBesAo1/ VgSjf+giw6lzor5Kl4UcXufBev1A9diGflZkZRMu4ujfcuoofgum6dCM6Cfj3jGXm3vN 8C0fqeuBCWXqJQXnOeu3wRc04LkEY/eA83ae0z/xfFopbE3QuK+Ox6ylyPdcFNPx0zul Zy+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LyYH1vUOROUp+ALOi+AoU+6fL4aHHF4lo5SZlCQc25A=; b=jcL7ZmFofyWNn+OwNkuFmqNW/sIXhSE93CAqrt4VPN/v9lcvjGslQzn8aqOQSehEd6 38CT1N6REJkKJ7aiZqGlw0wqTU1gRmHkTfmWIShe3pt3a+89YUsi9kovpM8rIJ1Mclha inkCepg4DfL1kN8YHkGVT7dHUrHTYZFQeXkZqgcegjwLlJhYYHojxfR3kz8R1aFYIQuw ZvPJXlg3KyP+JyXssFuY0wLiEsG+2K8s3PapZSrAcswgjhqqj1YWwuEH0IdLHNyPSXiF iGld4r52mRTih8WxloO71b0xNjUJhHFyliwl8wmfExq3LJwtsC022QgMGtzbmD3nHr6k W1Vw== X-Gm-Message-State: AGi0PuaFdMTYtkY8D83R83fKqBc2CExRANRW5WbDRcK73cYojPDqFHug 44JBse8hnx+Y3zeKPFEtAEUDFQ== X-Google-Smtp-Source: APiQypI01tCXhk3gNbophIDXmJ2bhrGBHZHya+6Zsexa8ww7+rizey/8n3ivJMuKt38628ELoCF1Ig== X-Received: by 2002:a1c:7ed7:: with SMTP id z206mr1406655wmc.64.1586894794435; Tue, 14 Apr 2020 13:06:34 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 02/17] exec/cpu-all: Use bool for have_guest_base Date: Tue, 14 Apr 2020 21:06:16 +0100 Message-Id: <20200414200631.12799-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Richard Henderson , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Richard Henderson Signed-off-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/exec/cpu-all.h | 2 +- bsd-user/main.c | 4 ++-- linux-user/main.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 49384bb66a5..b4fb5832c4a 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -159,7 +159,7 @@ static inline void tswap64s(uint64_t *s) * This allows the guest address space to be offset to a convenient locati= on. */ extern unsigned long guest_base; -extern int have_guest_base; +extern bool have_guest_base; extern unsigned long reserved_va; =20 #if HOST_LONG_BITS <=3D TARGET_VIRT_ADDR_SPACE_BITS diff --git a/bsd-user/main.c b/bsd-user/main.c index 770c2b267ad..aef5531628a 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -42,7 +42,7 @@ int singlestep; unsigned long mmap_min_addr; unsigned long guest_base; -int have_guest_base; +bool have_guest_base; unsigned long reserved_va; =20 static const char *interp_prefix =3D CONFIG_QEMU_INTERP_PREFIX; @@ -828,7 +828,7 @@ int main(int argc, char **argv) } } else if (!strcmp(r, "B")) { guest_base =3D strtol(argv[optind++], NULL, 0); - have_guest_base =3D 1; + have_guest_base =3D true; } else if (!strcmp(r, "drop-ld-preload")) { (void) envlist_unsetenv(envlist, "LD_PRELOAD"); } else if (!strcmp(r, "bsd")) { diff --git a/linux-user/main.c b/linux-user/main.c index 1d20a83d4e8..90ad365b439 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -59,7 +59,7 @@ static const char *cpu_type; static const char *seed_optarg; unsigned long mmap_min_addr; unsigned long guest_base; -int have_guest_base; +bool have_guest_base; =20 /* * Used to implement backwards-compatibility for the `-strace`, and @@ -334,7 +334,7 @@ static void handle_arg_cpu(const char *arg) static void handle_arg_guest_base(const char *arg) { guest_base =3D strtol(arg, NULL, 0); - have_guest_base =3D 1; + have_guest_base =3D true; } =20 static void handle_arg_reserved_va(const char *arg) --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586894968; cv=none; d=zohomail.com; s=zohoarc; b=gYwDJlFFk1Y59cQFaltUUAtZl6NqPC8eZINdwxTci5cphJxcVZbY0CUqMC0MRxIo/cDZXIT2d68IRSVsJMBb0KKFc2Ijqawu3Iw8WSXkHuoKM8tURv23ESMZtG+SVeZQ3VQITjr13083MLgeL/IVbFf1KtVshoAEXs/QqYz6O1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586894968; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NOU8+nMEIGED2iJZhktWL6KnvYhctO6T5v6pR87w3Mo=; b=cLHJGLyqC1/r/1V65wC6L+Q63Ynr+u9ax+eR57Lmzqmi8z2IZPQAWlFTvV701AuuLKud8qQIMyDDt9hy5mQUd0ZbKWiKagUDums9d8UUpTb/VZkzJix2b3QhXI2v8MRzLDzQRoW3lSQ3wUUooXS83u/Ey03C7NR2SI/TvPjOGLc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586894968615676.2717758212126; Tue, 14 Apr 2020 13:09:28 -0700 (PDT) Received: from localhost ([::1]:38396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORs7-0002e7-C1 for importer@patchew.org; Tue, 14 Apr 2020 16:09:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44444) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpQ-0005ut-R8 for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpP-0005ue-GQ for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:40 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:42770) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpP-0005uF-AK for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:39 -0400 Received: by mail-wr1-x443.google.com with SMTP id j2so16014403wrs.9 for ; Tue, 14 Apr 2020 13:06:39 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id v1sm15855007wrv.19.2020.04.14.13.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E5C4E1FF8F; Tue, 14 Apr 2020 21:06:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NOU8+nMEIGED2iJZhktWL6KnvYhctO6T5v6pR87w3Mo=; b=mjCsPmuoughxp2LFW8AqP6K9VjuIgM5qLtRrDGoyhOZ827z4tTBSm1EN6iMC/LrnUT SjW90UCu66krkF3TGUKx+Zqc/+AqSvmleQmIgr9MbU+S8OuvFkaywELX2NIwMWPESOJw RlyJrM3V8bZswbUY7JmLbDWaDYrTZxLaWk0PBPRONIvTqQt6WXvLLABXQDR63H/FNxwa NVaSaPEL9LBbPdeWSzWxvUyoLSrXljzGIo+TRLSmkS+AsQnP3k8Rs9wWwDJEUCWbA3uT +c1hNLk1x+BuzmXY4c3tQOdGODYc73xeeU3tZYM+6jD5sKCR5D+xXDrfWyia2T6Th6x3 c08Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NOU8+nMEIGED2iJZhktWL6KnvYhctO6T5v6pR87w3Mo=; b=NtOhGcTRaLcj9uQpmI1b0+vkYT/m0VEv9SdhzF6uyKH8Qb5g9rNoLWcUS1dR0d2E+x ODnwb3UuXeypHkQDAL0l4GJNrc6S2d6l/nKN8YCMX0QOH6MMNN+B4UF16f7QJYLwit2H ArwMhaH69OJsJfe5dPeUpmaC8MEQHgjd0XOtkeEwq4crnNP+zHXE86XO875J6M4XDn6E rQohsYddezZf4O+tXLI1ZmDhVipAnqjQ9X6kyLsvOx4fkTxT1OjExi2ePanieFOkXveM GtbBzDA/Aps3y+qTv6eFXF34x/YstHZlBMEkM/IUTY7v29iOHIBUiAXRYgDEpQKUHKvt LWGg== X-Gm-Message-State: AGi0PuYWQ3OfPm3pksZUebtFYKVvVT0oAewebAqLd+iZBYnFZ3f+Ew0e hzlzTVE6MpwjXvCipRJpLLoIGg== X-Google-Smtp-Source: APiQypKyxfdfMAhXePnNUwkyhPlGQ0fmpP6F7zO+4ZTd3/HfXZdnNXY3r9alCEACwBsycmvnec4WIg== X-Received: by 2002:a5d:4404:: with SMTP id z4mr20300751wrq.316.1586894798275; Tue, 14 Apr 2020 13:06:38 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 03/17] accel/tcg: Relax va restrictions on 64-bit guests Date: Tue, 14 Apr 2020 21:06:17 +0100 Message-Id: <20200414200631.12799-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Richard Henderson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Richard Henderson We cannot at present limit a 64-bit guest to a virtual address space smaller than the host. It will mostly work to ignore this limitation, except if the guest uses high bits of the address space for tags. But it will certainly work better, as presently we can wind up failing to allocate the guest stack. Widen our user-only page tree to the host or abi pointer width. Remove the workaround for this problem from target/alpha. Always validate guest addresses vs reserved_va, as there we control allocation ourselves. Signed-off-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- include/exec/cpu-all.h | 23 +++++++++++++++++++---- target/alpha/cpu-param.h | 15 ++------------- accel/tcg/translate-all.c | 15 +++++++++------ 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index b4fb5832c4a..c0c2fa3cc56 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -162,12 +162,27 @@ extern unsigned long guest_base; extern bool have_guest_base; extern unsigned long reserved_va; =20 -#if HOST_LONG_BITS <=3D TARGET_VIRT_ADDR_SPACE_BITS -#define GUEST_ADDR_MAX (~0ul) +/* + * Limit the guest addresses as best we can. + * + * When not using -R reserved_va, we cannot really limit the guest + * to less address space than the host. For 32-bit guests, this + * acts as a sanity check that we're not giving the guest an address + * that it cannot even represent. For 64-bit guests... the address + * might not be what the real kernel would give, but it is at least + * representable in the guest. + * + * TODO: Improve address allocation to avoid this problem, and to + * avoid setting bits at the top of guest addresses that might need + * to be used for tags. + */ +#if MIN(TARGET_VIRT_ADDR_SPACE_BITS, TARGET_ABI_BITS) <=3D 32 +# define GUEST_ADDR_MAX_ UINT32_MAX #else -#define GUEST_ADDR_MAX (reserved_va ? reserved_va - 1 : \ - (1ul << TARGET_VIRT_ADDR_SPACE_BITS) -= 1) +# define GUEST_ADDR_MAX_ ~0ul #endif +#define GUEST_ADDR_MAX (reserved_va ? reserved_va - 1 : GUEST_ADDR_MAX_) + #else =20 #include "exec/hwaddr.h" diff --git a/target/alpha/cpu-param.h b/target/alpha/cpu-param.h index 692aee27ca9..1153992e42a 100644 --- a/target/alpha/cpu-param.h +++ b/target/alpha/cpu-param.h @@ -10,22 +10,11 @@ =20 #define TARGET_LONG_BITS 64 #define TARGET_PAGE_BITS 13 -#ifdef CONFIG_USER_ONLY -/* - * ??? The kernel likes to give addresses in high memory. If the host has - * more virtual address space than the guest, this can lead to impossible - * allocations. Honor the long-standing assumption that only kernel addrs - * are negative, but otherwise allow allocations anywhere. This could lead - * to tricky emulation problems for programs doing tagged addressing, but - * that's far fewer than encounter the impossible allocation problem. - */ -#define TARGET_PHYS_ADDR_SPACE_BITS 63 -#define TARGET_VIRT_ADDR_SPACE_BITS 63 -#else + /* ??? EV4 has 34 phys addr bits, EV5 has 40, EV6 has 44. */ #define TARGET_PHYS_ADDR_SPACE_BITS 44 #define TARGET_VIRT_ADDR_SPACE_BITS (30 + TARGET_PAGE_BITS) -#endif + #define NB_MMU_MODES 3 =20 #endif diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 9924e66d1f7..e4f703a7e6d 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -173,8 +173,13 @@ struct page_collection { #define TB_FOR_EACH_JMP(head_tb, tb, n) \ TB_FOR_EACH_TAGGED((head_tb)->jmp_list_head, tb, n, jmp_list_next) =20 -/* In system mode we want L1_MAP to be based on ram offsets, - while in user mode we want it to be based on virtual addresses. */ +/* + * In system mode we want L1_MAP to be based on ram offsets, + * while in user mode we want it to be based on virtual addresses. + * + * TODO: For user mode, see the caveat re host vs guest virtual + * address spaces near GUEST_ADDR_MAX. + */ #if !defined(CONFIG_USER_ONLY) #if HOST_LONG_BITS < TARGET_PHYS_ADDR_SPACE_BITS # define L1_MAP_ADDR_SPACE_BITS HOST_LONG_BITS @@ -182,7 +187,7 @@ struct page_collection { # define L1_MAP_ADDR_SPACE_BITS TARGET_PHYS_ADDR_SPACE_BITS #endif #else -# define L1_MAP_ADDR_SPACE_BITS TARGET_VIRT_ADDR_SPACE_BITS +# define L1_MAP_ADDR_SPACE_BITS MIN(HOST_LONG_BITS, TARGET_ABI_BITS) #endif =20 /* Size of the L2 (and L3, etc) page tables. */ @@ -2497,9 +2502,7 @@ void page_set_flags(target_ulong start, target_ulong = end, int flags) /* This function should never be called with addresses outside the guest address space. If this assert fires, it probably indicates a missing call to h2g_valid. */ -#if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS - assert(end <=3D ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS)); -#endif + assert(end - 1 <=3D GUEST_ADDR_MAX); assert(start < end); assert_memory_lock(); =20 --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586894883; cv=none; d=zohomail.com; s=zohoarc; b=dwJu0LZ9R1SZ1dsyFT4FA140dyy8kF/+518Adpoo9jgFs/uHgav7AJ1QRJDhu/q9fAm8hTAxAnOyFfASfH3NFMnLG7vFRDk/PNQfW8lNxyYv1a4REoCoyglzf010ouvgUdFZJJs2Xd6Ex6saDTh9ez8jVUzjniM+WobbfwhIrns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586894883; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9ptCwd/BWCtSQi+ZJyFjq9rFc58i3OUw5zJJkXD91Vg=; b=hWHaJ9l21SUHlDcMZ8mVBHWEtwybd8wBISGk3/fD0w5QBalngmBRjZOjSBf8hMbRSTAPnUkac8Ct8taU3pV2oxDhDn6o1hd4QVhqvC1Asy04NdtMozRYHRjGQUv3Ue214ZGRBg2LiOODr249utc4MqKgpwkdP/IgTl2FOgun1qg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586894883608909.0192065940704; Tue, 14 Apr 2020 13:08:03 -0700 (PDT) Received: from localhost ([::1]:38352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORqk-0007do-6N for importer@patchew.org; Tue, 14 Apr 2020 16:08:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44460) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpR-0005wm-O1 for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpQ-0005vD-Rh for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:41 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:55531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpQ-0005uo-LI for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:40 -0400 Received: by mail-wm1-x329.google.com with SMTP id e26so14519210wmk.5 for ; Tue, 14 Apr 2020 13:06:40 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q4sm21416156wmj.1.2020.04.14.13.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 173811FF90; Tue, 14 Apr 2020 21:06:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9ptCwd/BWCtSQi+ZJyFjq9rFc58i3OUw5zJJkXD91Vg=; b=a4IWk+DZy2PglXYjno1snkpgc3RTKB4rcida2gYlPyIullfzGuxZgTgIv2yjAvnmpu gCea0wLVCVG2BXjPJ0asCN73JynyDO5Z25ZtA9egGHRkwD0x/Bw8fhKxJyoCuB3KfOO9 CuFtIq/D9aClq//VrRHrP61k/JAA90LMzICpGBP697qfWPHVbZngxeS9o777bUVj0Rwx fGt/CrvfdWG2n2DRoJ445ZuEteXOAzcc7G1JJ6GiP7RjHBSxqTTtxn53xtdYDQ3jZv8d 2VZuIH46vZ4Y2WgvMlTUS6ercjmXmtY9PTWA3EUG67Z+5n6I0zI0qTTby296cIL8jusf a6cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9ptCwd/BWCtSQi+ZJyFjq9rFc58i3OUw5zJJkXD91Vg=; b=f3SLgxBjGqidFv6vBaUNDsrICiHR5ooMyaoGBaA4vBDIoNzm7uXJY4dkDPPD+gUveL qUQ8wE0t22BlasVfp6vQPFa9DnjCQUzrOYj3m70+YY5OpAAqRusXyhVPcd62OpQzqCHG Ddi7aIt5Kbl0VziEhTaU+pDZaA42FhVIPxPnoRYKN9Y7o+B9bSk607gp+beA3q9dqEBh 0uZWB4OEJ80VrkqpqFuhdxBox/BSMze6ttOCtKp22V24GDLlWR/rBZKZkGHR7tC/S/qu aP33THDtPPZeqxSHhySF3FSQyzihjMzqHiEeTrNz4puq7zV7ru2GyAhjxAD/ajAsYuHO 7ZAg== X-Gm-Message-State: AGi0PuZ6o9vhkoYgzgzZSUPnjfU7mDMLXovD6nlG3KMvvAi7tbennlkt P/df55MS6Ft2YFJlLeL2eAPaCHfTgdw= X-Google-Smtp-Source: APiQypLh9kf2Hwe65mdupU0NiT9CVnW14hK8ToD5n/YAm1NJ1lD7glAU1ZqNJ0iePuENuxK38wxjaA== X-Received: by 2002:a1c:a553:: with SMTP id o80mr1627354wme.154.1586894799652; Tue, 14 Apr 2020 13:06:39 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 04/17] .gitignore: include common build sub-directories Date: Tue, 14 Apr 2020 21:06:18 +0100 Message-Id: <20200414200631.12799-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As out-of-tree builds become more common (or rather building in a subdir) we can add a lot of load to "git ls-files" as it hunts down sub-directories that are irrelevant to the source tree. This is especially annoying if you have a prompt that attempts to summarise the current git status on command completion. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- v2 - use build*/ to capture build and it's variants --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0c5af83aa74..8dccb61a44e 100644 --- a/.gitignore +++ b/.gitignore @@ -141,6 +141,7 @@ cscope.* tags TAGS docker-src.* +build*/ *~ *.ast_raw *.depend_raw --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586895251; cv=none; d=zohomail.com; s=zohoarc; b=JZj79ngm5gN0YdNClUzKmPSbE9hMPvkSBadbPSWtKHIgREZOcKUg0HzByt0cL7z/VjS385eO5xs/aWaWTMc65Ly4+e/YdUb2i7TQd7kHZYBNfDt2CG4vfgz4KxNq8savHybq8/nHtus6WePTTMJQ2UZkulEaxbWYjB8vN/L1tIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586895251; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=en3XxeI0kUhj1g+8oDCU8qm2/eo411eCLElDQvibSv4=; b=kjoP7tevP2UrEj78bn3UV2wgsIBmLsKO+tWtnEztisaSVZQWEaWV1M5Rwq/sD/+lzQuWswlIFQXlPW8evp1ViY8ynXX6KaxtRlmxNg1TIEtvbnVCWJtafq9H5O0wcQ72v5nnQAw2G7DU1Q/Q5d+moPDzM1qx01wMDx9D/ORbzkI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586895251191337.34732862441865; Tue, 14 Apr 2020 13:14:11 -0700 (PDT) Received: from localhost ([::1]:38498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORwf-0000ns-Qg for importer@patchew.org; Tue, 14 Apr 2020 16:14:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44492) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpU-000617-Kp for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpT-0005wW-6u for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:44 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:39755) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpT-0005wK-0U for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:43 -0400 Received: by mail-wm1-x341.google.com with SMTP id y24so15737876wma.4 for ; Tue, 14 Apr 2020 13:06:42 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y9sm19405924wmm.26.2020.04.14.13.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3AD241FF91; Tue, 14 Apr 2020 21:06:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=en3XxeI0kUhj1g+8oDCU8qm2/eo411eCLElDQvibSv4=; b=A7BCqQq3N+Wg72bkKjkAjNpf8sRBALo3rR1DHkl0MeO1HpWECTMdvIR4BgVqeLVY2M S9/ZFG2WHFHiaQ+rBEUzzd/H4jjOboS5wq/nAgDZSNXzeAziS/Cd/PMq+LQMd/mJVh9u vk1LBwC20ovfwekRoiMuYt85RGZ9tlsbo2x/zu/NbnMIvFy3Bb3GbFPw8O+oWuKfyjLY JpqAH2gv2efRDNNvdTa4C/dSyJ8auSM3qhFSdZC3qeXQLGs/WkIh4lJsrobSENQvB0uG ZQDuHxL5CJdCT5pSddpvx1I4UJlCUiWC1RHIfM9TKPvnaP03E2pW/AKIPfUy/FyVuyf0 Hxww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=en3XxeI0kUhj1g+8oDCU8qm2/eo411eCLElDQvibSv4=; b=WruGjUiYP/De4EYNKY+Z8CVLfm/r3dDmE6VMxMUyOXGIIy1L/f4pCMVI1dHRiVosEI Z2hWuXcKx2D2A+JOUaVZZRrrwFPO5AkUBQOZqCJTxMeZTvr/+tdbxIcNQKT+hzEb2D02 yM4k4idjqa8VPBTyDHaipv0cCsRU8awwVbyzlqtRnjSzhQ25Or54rd2Lpwyy8t6BToxT 35iVQD4vTseJ2mshUqFBMHsB8lYg0Ax2uhYHgyGEo6DaI0ruP616ikjFU5nkbnQFUZZh HDGlSSdmLG9ImCq3IJdJ5Z5gqQkM9gRmhmzn2yFRdNvSZlS0qeqyFft4pFEpKy5Tk9Ot FBzA== X-Gm-Message-State: AGi0PuZNWgRfNlr7Qg8Y1s2I4x8GDBs7GC2uhoqLLYwD2O0URkbs65Ew f+vgT0WMmwyqkf2rjtASylG+mA== X-Google-Smtp-Source: APiQypIf2fpYW3p8BiEg/hksgpPmsBtHSHfY3BnneXKQaCTzZpVI6QADBnnw7z0f+9XSfnmd6Q5Rtg== X-Received: by 2002:a1c:e187:: with SMTP id y129mr1574429wmg.133.1586894802006; Tue, 14 Apr 2020 13:06:42 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 05/17] linux-user/ppc: Fix padding in mcontext_t for ppc64 Date: Tue, 14 Apr 2020 21:06:19 +0100 Message-Id: <20200414200631.12799-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Riku Voipio , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Richard Henderson The padding that was added in 95cda4c44ee was added to a union, and so it had no effect. This fixes misalignment errors detected by clang sanitizers for ppc64 and ppc64le. In addition, only ppc64 allocates space for VSX registers, so do not save them for ppc32. The kernel only has references to CONFIG_SPE in signal_32.c, so do not attempt to save them for ppc64. Fixes: 95cda4c44ee Signed-off-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- linux-user/ppc/signal.c | 69 +++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 40 deletions(-) diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index ecd99736b7e..20a02c197cb 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -35,12 +35,26 @@ struct target_mcontext { target_ulong mc_gregs[48]; /* Includes fpscr. */ uint64_t mc_fregs[33]; + #if defined(TARGET_PPC64) /* Pointer to the vector regs */ target_ulong v_regs; + /* + * On ppc64, this mcontext structure is naturally *unaligned*, + * or rather it is aligned on a 8 bytes boundary but not on + * a 16 byte boundary. This pad fixes it up. This is why we + * cannot use ppc_avr_t, which would force alignment. This is + * also why the vector regs are referenced in the ABI by the + * v_regs pointer above so any amount of padding can be added here. + */ + target_ulong pad; + /* VSCR and VRSAVE are saved separately. Also reserve space for VSX. = */ + struct { + uint64_t altivec[34 + 16][2]; + } mc_vregs; #else target_ulong mc_pad[2]; -#endif + /* We need to handle Altivec and SPE at the same time, which no kernel needs to do. Fortunately, the kernel defines this bit to be Altivec-register-large all the time, rather than trying to @@ -48,32 +62,14 @@ struct target_mcontext { union { /* SPE vector registers. One extra for SPEFSCR. */ uint32_t spe[33]; - /* Altivec vector registers. The packing of VSCR and VRSAVE - varies depending on whether we're PPC64 or not: PPC64 splits - them apart; PPC32 stuffs them together. - We also need to account for the VSX registers on PPC64 - */ -#if defined(TARGET_PPC64) -#define QEMU_NVRREG (34 + 16) - /* On ppc64, this mcontext structure is naturally *unaligned*, - * or rather it is aligned on a 8 bytes boundary but not on - * a 16 bytes one. This pad fixes it up. This is also why the - * vector regs are referenced by the v_regs pointer above so - * any amount of padding can be added here - */ - target_ulong pad; -#else - /* On ppc32, we are already aligned to 16 bytes */ -#define QEMU_NVRREG 33 -#endif - /* We cannot use ppc_avr_t here as we do *not* want the implied - * 16-bytes alignment that would result from it. This would have - * the effect of making the whole struct target_mcontext aligned - * which breaks the layout of struct target_ucontext on ppc64. + /* + * Altivec vector registers. One extra for VRSAVE. + * On ppc32, we are already aligned to 16 bytes. We could + * use ppc_avr_t, but choose to share the same type as ppc64. */ - uint64_t altivec[QEMU_NVRREG][2]; -#undef QEMU_NVRREG + uint64_t altivec[33][2]; } mc_vregs; +#endif }; =20 /* See arch/powerpc/include/asm/sigcontext.h. */ @@ -278,6 +274,7 @@ static void save_user_regs(CPUPPCState *env, struct tar= get_mcontext *frame) __put_user((uint32_t)env->spr[SPR_VRSAVE], vrsave); } =20 +#if defined(TARGET_PPC64) /* Save VSX second halves */ if (env->insns_flags2 & PPC2_VSX) { uint64_t *vsregs =3D (uint64_t *)&frame->mc_vregs.altivec[34]; @@ -286,6 +283,7 @@ static void save_user_regs(CPUPPCState *env, struct tar= get_mcontext *frame) __put_user(*vsrl, &vsregs[i]); } } +#endif =20 /* Save floating point registers. */ if (env->insns_flags & PPC_FLOAT) { @@ -296,22 +294,18 @@ static void save_user_regs(CPUPPCState *env, struct t= arget_mcontext *frame) __put_user((uint64_t) env->fpscr, &frame->mc_fregs[32]); } =20 +#if !defined(TARGET_PPC64) /* Save SPE registers. The kernel only saves the high half. */ if (env->insns_flags & PPC_SPE) { -#if defined(TARGET_PPC64) - for (i =3D 0; i < ARRAY_SIZE(env->gpr); i++) { - __put_user(env->gpr[i] >> 32, &frame->mc_vregs.spe[i]); - } -#else for (i =3D 0; i < ARRAY_SIZE(env->gprh); i++) { __put_user(env->gprh[i], &frame->mc_vregs.spe[i]); } -#endif /* Set MSR_SPE in the saved MSR value to indicate that frame->mc_vregs contains valid data. */ msr |=3D MSR_SPE; __put_user(env->spe_fscr, &frame->mc_vregs.spe[32]); } +#endif =20 /* Store MSR. */ __put_user(msr, &frame->mc_gregs[TARGET_PT_MSR]); @@ -392,6 +386,7 @@ static void restore_user_regs(CPUPPCState *env, __get_user(env->spr[SPR_VRSAVE], vrsave); } =20 +#if defined(TARGET_PPC64) /* Restore VSX second halves */ if (env->insns_flags2 & PPC2_VSX) { uint64_t *vsregs =3D (uint64_t *)&frame->mc_vregs.altivec[34]; @@ -400,6 +395,7 @@ static void restore_user_regs(CPUPPCState *env, __get_user(*vsrl, &vsregs[i]); } } +#endif =20 /* Restore floating point registers. */ if (env->insns_flags & PPC_FLOAT) { @@ -412,22 +408,15 @@ static void restore_user_regs(CPUPPCState *env, env->fpscr =3D (uint32_t) fpscr; } =20 +#if !defined(TARGET_PPC64) /* Save SPE registers. The kernel only saves the high half. */ if (env->insns_flags & PPC_SPE) { -#if defined(TARGET_PPC64) - for (i =3D 0; i < ARRAY_SIZE(env->gpr); i++) { - uint32_t hi; - - __get_user(hi, &frame->mc_vregs.spe[i]); - env->gpr[i] =3D ((uint64_t)hi << 32) | ((uint32_t) env->gpr[i]= ); - } -#else for (i =3D 0; i < ARRAY_SIZE(env->gprh); i++) { __get_user(env->gprh[i], &frame->mc_vregs.spe[i]); } -#endif __get_user(env->spe_fscr, &frame->mc_vregs.spe[32]); } +#endif } =20 #if !defined(TARGET_PPC64) --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586895155; cv=none; d=zohomail.com; s=zohoarc; b=ajA/5ihhNTqCP1b4yPnRPn+IE0CNTs1KU0PdSCjbWelGVrRVCBjDQd0TaLDY/y+Q8YLTtx/p+avt52+UoE0kQh3YbWqOX6l05gZrwRuScMciLpYS6auWgsih9xIOSr7G/PchoRTZALejt4hYatOODY6VKq9CfNuUFnDXyIcGSSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586895155; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MKNqRiBPCPZs1Nb8xQ+iMkO9ECJezVjcKyg7f8B8t6U=; b=QLjoMuj6Fxk4ebeUcNNlBHC/e7/qAzclvxnYXOKds6173PpVsxpEPVPtdqfBaF+jrMBIb5vaqIqbCmI057OovxjKBtejcejRK9myMsdqCtPlP7SGGP7Pjb2+nadCbPolR+5KHv0LzbbXiZRzTtwQdgrBb931npTeMEUGdZEoxp8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586895155212453.5976557260625; Tue, 14 Apr 2020 13:12:35 -0700 (PDT) Received: from localhost ([::1]:38484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORv8-0007m5-08 for importer@patchew.org; Tue, 14 Apr 2020 16:12:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44478) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpT-0005zL-QN for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpS-0005w7-8Z for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:43 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:50380) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpS-0005vX-23 for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:42 -0400 Received: by mail-wm1-x330.google.com with SMTP id x25so14524468wmc.0 for ; Tue, 14 Apr 2020 13:06:42 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q8sm19482844wmg.22.2020.04.14.13.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 85FC81FF92; Tue, 14 Apr 2020 21:06:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MKNqRiBPCPZs1Nb8xQ+iMkO9ECJezVjcKyg7f8B8t6U=; b=l5x/H0FzNGEL47GRnzCGTQS6UHX8GrWNGh8RgaP/OSqthAsQt7FUL+Hfr1dMv6rWEO EZ6+Zc/5uKFNU6G9VKyq7C8cFPZ8SWm8jkjAqU8wLI+/JR02HjKCjLqFN1avOR/W+dAa S3gh/De7w+cjua5rPeZloCg0DrNKMKjTnuUStGSaQJTqOuM+e8W4hx7NvHJ9wAnyCXBu Bm2aZgY16Kz1RcCv2QTbsDTYt8jvz6szJmH1DjfdlxWLDvOfvcPVtmr+nJunHvDZz+Iq ydEEZFe2DjuSsRq2K8cnzdx0EK5gAa0MwggbZRSTT59Jor6eUbK/A6tYu8h7Ph1dF9Zm 0sNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MKNqRiBPCPZs1Nb8xQ+iMkO9ECJezVjcKyg7f8B8t6U=; b=TAQumhpec74LCIGG2g4AWKX9B+dFBzcW8du7CDjRUToJubtPVxB60bhP4h6wvVG2JJ A4H1BU58GhBP56STc+CDdAB3p9W2Q+GI6avZxTUq5ibj/BtnsrzQ6MWOvHZK/KQuTmBo nOAL+sRkaG10cRxRMVPWf8+VNyi8dPd+CFMrrLApcRK+rH+URnGK+JB7ZoXGPr07xGkC FSW8oh5LgYDprQP4h+rQNPGgOrZLjY1aJdrBD/F677LOkdCj9hJwTuZsosfU4rkTeVor 5+bFdudDlp9APEiP23K14VywEPX5sr2tvWo517I0kmZdKqsna8/ocB2jF/2Jct5KVmyi fFQg== X-Gm-Message-State: AGi0PubNMiYbuohRkz5AYUShKXE3MjJ36g3j4QiqKaXugr7TQNf0Tq2K 8pJW69oaG7v9iy+TTfDHf0pUYlVHlGg= X-Google-Smtp-Source: APiQypI6PdXiEd++tF4vra0RNIsWkoKeZbDQmijSGTs4/drkAYyBvMSZWxt6YijeW3YXlN6/s3GuXg== X-Received: by 2002:a1c:e242:: with SMTP id z63mr1586134wmg.72.1586894800990; Tue, 14 Apr 2020 13:06:40 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 06/17] tests/docker: add docs FEATURE flag and use for test-misc Date: Tue, 14 Apr 2020 21:06:20 +0100 Message-Id: <20200414200631.12799-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::330 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The test-misc docker test fails on a number of images which don't have the prerequisites to build the docs. Use the FEATURES flag so we can skip those tests. As the sphinx test fails to detect whatever feature we need to get hxtool to work we drop them from debian9 so the windows build doesn't attempt to build the docs. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- tests/docker/dockerfiles/debian10.docker | 2 ++ tests/docker/dockerfiles/debian9.docker | 2 -- tests/docker/dockerfiles/fedora.docker | 2 +- tests/docker/dockerfiles/travis.docker | 2 +- tests/docker/dockerfiles/ubuntu.docker | 2 +- tests/docker/dockerfiles/ubuntu1804.docker | 2 +- tests/docker/test-misc | 2 ++ 7 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/docker/dockerfiles/debian10.docker b/tests/docker/docker= files/debian10.docker index 2fcdc406e83..0769700a416 100644 --- a/tests/docker/dockerfiles/debian10.docker +++ b/tests/docker/dockerfiles/debian10.docker @@ -34,3 +34,5 @@ RUN apt update && \ python3-sphinx \ texinfo \ $(apt-get -s build-dep qemu | egrep ^Inst | fgrep '[all]' | cut -d= \ -f2) + +ENV FEATURES docs diff --git a/tests/docker/dockerfiles/debian9.docker b/tests/docker/dockerf= iles/debian9.docker index 92edbbf0f48..08cc970feb1 100644 --- a/tests/docker/dockerfiles/debian9.docker +++ b/tests/docker/dockerfiles/debian9.docker @@ -30,6 +30,4 @@ RUN apt update && \ pkg-config \ psmisc \ python3 \ - python3-sphinx \ - texinfo \ $(apt-get -s build-dep qemu | egrep ^Inst | fgrep '[all]' | cut -d= \ -f2) diff --git a/tests/docker/dockerfiles/fedora.docker b/tests/docker/dockerfi= les/fedora.docker index 4bd2c953af8..179575ecaaa 100644 --- a/tests/docker/dockerfiles/fedora.docker +++ b/tests/docker/dockerfiles/fedora.docker @@ -103,4 +103,4 @@ ENV QEMU_CONFIGURE_OPTS --python=3D/usr/bin/python3 RUN dnf install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txt ENV PATH $PATH:/usr/libexec/python3-sphinx/ -ENV FEATURES mingw clang pyyaml asan +ENV FEATURES mingw clang pyyaml asan docs diff --git a/tests/docker/dockerfiles/travis.docker b/tests/docker/dockerfi= les/travis.docker index e8eb48dccfd..591282561bc 100644 --- a/tests/docker/dockerfiles/travis.docker +++ b/tests/docker/dockerfiles/travis.docker @@ -13,5 +13,5 @@ RUN apt-get -y install device-tree-compiler python3 pytho= n3-yaml dh-autoreconf g # Travis tools require PhantomJS / Neo4j / Maven accessible # in their PATH (QEMU build won't access them). ENV PATH /usr/local/phantomjs/bin:/usr/local/phantomjs:/usr/local/neo4j-3.= 2.7/bin:/usr/local/maven-3.5.2/bin:/usr/local/cmake-3.9.2/bin:/usr/local/cl= ang-5.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -ENV FEATURES clang pyyaml +ENV FEATURES clang pyyaml docs USER travis diff --git a/tests/docker/dockerfiles/ubuntu.docker b/tests/docker/dockerfi= les/ubuntu.docker index b6c7b41dddd..eeb3b22bf20 100644 --- a/tests/docker/dockerfiles/ubuntu.docker +++ b/tests/docker/dockerfiles/ubuntu.docker @@ -68,4 +68,4 @@ ENV PACKAGES flex bison \ RUN apt-get update && \ DEBIAN_FRONTEND=3Dnoninteractive apt-get -y install $PACKAGES RUN dpkg -l $PACKAGES | sort > /packages.txt -ENV FEATURES clang pyyaml sdl2 +ENV FEATURES clang pyyaml sdl2 docs diff --git a/tests/docker/dockerfiles/ubuntu1804.docker b/tests/docker/dock= erfiles/ubuntu1804.docker index 1efedeef995..f66b06f4cff 100644 --- a/tests/docker/dockerfiles/ubuntu1804.docker +++ b/tests/docker/dockerfiles/ubuntu1804.docker @@ -54,7 +54,7 @@ ENV PACKAGES flex bison \ RUN apt-get update && \ DEBIAN_FRONTEND=3Dnoninteractive apt-get -y install $PACKAGES RUN dpkg -l $PACKAGES | sort > /packages.txt -ENV FEATURES clang pyyaml sdl2 +ENV FEATURES clang pyyaml sdl2 docs =20 # https://bugs.launchpad.net/qemu/+bug/1838763 ENV QEMU_CONFIGURE_OPTS --disable-libssh diff --git a/tests/docker/test-misc b/tests/docker/test-misc index d480afedca7..cc94a738dd0 100755 --- a/tests/docker/test-misc +++ b/tests/docker/test-misc @@ -14,6 +14,8 @@ =20 . common.rc =20 +requires docs + cd "$BUILD_DIR" =20 # build everything else but QEMU --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586894887; cv=none; d=zohomail.com; s=zohoarc; b=KSQxAAYN16kjVOTNrsCFuTAeot/rVc6SloSNcZgZXCozErxZ631+xewj1a9IaNqPSjhsgy2BIDi9frASYWbzQyDw4JnQz/11/aG1TcC6Xt7+MxbrOvRZtLnPCQwDt6M1YtsZbnszn2BLkjrT4BvpZJj5d4hk+NH6ZXnEbza9l+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586894887; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Stc4FSJiUzlY3FsuzLYHemmHJ45cRRBL4YVh1lfAAYo=; b=caHibjkcpwJd3plnhfmNYGeh/DtJLuSv+PsKivFOanXQ1wcpL6i1vfTmMHmOEcAS06GVDMox8p2A+EiYsLIFYEwb80SNAYVC0FciX2TgHU5eZnlTVH5Hp2L6eHoCmk0jrq0M9UKzGyB9IiHI7Y3lsN+Cqpzt8RT1V8K9zjSPZs4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586894887028699.398648423413; Tue, 14 Apr 2020 13:08:07 -0700 (PDT) Received: from localhost ([::1]:38356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORqn-0007nL-P0 for importer@patchew.org; Tue, 14 Apr 2020 16:08:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44510) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpV-00062m-NP for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpU-0005x1-LP for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:45 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:35777) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpU-0005wl-FG for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:44 -0400 Received: by mail-wm1-x32b.google.com with SMTP id r26so15788406wmh.0 for ; Tue, 14 Apr 2020 13:06:44 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y20sm21130075wra.79.2020.04.14.13.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AA7FC1FF93; Tue, 14 Apr 2020 21:06:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Stc4FSJiUzlY3FsuzLYHemmHJ45cRRBL4YVh1lfAAYo=; b=W8jcJe78mqjkvE6H+bdu8ofUq0cSwVmy6RU/hV5ucrYJUQjdhYExE1UkzzL8C6U4lk ORctGtC8la1fk29F9VFeOX8DNakh0o/HgD5vjlU2FAQdLBKyugjZfjGpsQbJsZ08Xkqy 9pT5FOgez7s6W3ozydc5zEadWEAL8gDTKkfLjqOrHildDpNZwYGTe6yA1WOQ4ee02DpJ 52YqE/KjUog3hMh9vttq+wRR4y4osAfxMksh0Ad98YVUL54tNLAA+Vc9d3839lOPgugp Tuj1R/MtvGLC2mHqO9d9gFvIx6bldpKB46hwORedIazkKNJS8HnolFykJ+NknNgNWlDQ k62w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Stc4FSJiUzlY3FsuzLYHemmHJ45cRRBL4YVh1lfAAYo=; b=aNdQ7X6dUZGSjuqX9qOimVTGbUSilZjNgf7gTEM86/TYR37EpjrL25HcemldhapMk9 G7u+wTvK2931JMjDn+0K8ECAu5ax5OkY3hNnUjctHfely4UBAjTrIqXjdQ7b7Ddu4pBM eq3asBhnGwnj3qFy7oHQ5LWRQ7tVwuGFkHyZbJzE5PdpdBMCZ84MdMtOaHA9L2r2V2yO /Ef2LEjCW4iKxL/Fb2wF8zxcWvfXXpxLyQfnZ+V7eiCfUWfZ5jg7n9n3LM3e68B8YeSK LkjqPV+mlNaR8hYlPLSMx82bV6+Qo7+lE0BtevTv6O5Yo3BoifnNg627pNNddO14afqy 52HA== X-Gm-Message-State: AGi0PuZT7wy8Xqow7uwXGq1v7Tlr2VG543cIBnCYutukZJYH3Jd4csey 1u4e8EoIgiJ1FSbq2ALjwQMH56RnTLI= X-Google-Smtp-Source: APiQypLMedX9vL+LX4Y+IWSMEHYbXa6P79jXySM4B/nf/jT6w4Vg4Rh+Wh9VES0DYml0lDPD0nHxlw== X-Received: by 2002:a1c:41d7:: with SMTP id o206mr1506122wma.89.1586894803480; Tue, 14 Apr 2020 13:06:43 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 07/17] configure: redirect sphinx-build check to config.log Date: Tue, 14 Apr 2020 21:06:21 +0100 Message-Id: <20200414200631.12799-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32b X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Otherwise it's hard to debug whats going on. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 9b1f5b33e45..25f7d915720 100755 --- a/configure +++ b/configure @@ -4942,7 +4942,9 @@ has_sphinx_build() { # sphinx-build doesn't exist at all or if it is too old. mkdir -p "$TMPDIR1/sphinx" touch "$TMPDIR1/sphinx/index.rst" - "$sphinx_build" $sphinx_werror -c "$source_path/docs" -b html "$TMPDIR= 1/sphinx" "$TMPDIR1/sphinx/out" >/dev/null 2>&1 + "$sphinx_build" $sphinx_werror -c "$source_path/docs" \ + -b html "$TMPDIR1/sphinx" \ + "$TMPDIR1/sphinx/out" >> config.log 2>&1 } =20 # Check if tools are available to build documentation. --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586894971; cv=none; d=zohomail.com; s=zohoarc; b=aSqO/hDL7sDeuEFbaJ4Def/sl7U2DSAHHF8yjy37KcGCzYWRVeu3vuM8SyoeYGEy5GpTm3vdKe+u4/PBqF9AlK1SyZFcZ+Uarei2YDxo54WGd8gWDyAzguwYlqwpWZxxnFpuytxdJt1CnjjFp/sj8kZ1FXnFH/vihHQQkJ4Lt0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586894971; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+FYvvrpeRy/LpnKiPLY9U4dRrQSytS7+4553ef7RHis=; b=FclLFgETqS02vP/WtgmiMXkwM17NwblsVDQ0U98HT+3eSGtI/QHj6g/yrB9uEzpmFbd2hl+AC2OC8ZNyG8v3ZAnOOJrUELwjHgacnT/6e8BejsW5PGpm9gdVRb2RThocyOJNyZzV5f+Gg31K6/q4Bf9cp+Zo1UZGmaHoYG5wvHE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586894971173598.2643330808559; Tue, 14 Apr 2020 13:09:31 -0700 (PDT) Received: from localhost ([::1]:38400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORs9-0002l5-Tj for importer@patchew.org; Tue, 14 Apr 2020 16:09:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44522) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpW-00064A-KY for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpV-0005xT-MO for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:46 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:39582) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpV-0005x7-G5 for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:45 -0400 Received: by mail-wm1-x335.google.com with SMTP id y24so15738120wma.4 for ; Tue, 14 Apr 2020 13:06:45 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id d133sm21285043wmc.27.2020.04.14.13.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D53081FF96; Tue, 14 Apr 2020 21:06:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+FYvvrpeRy/LpnKiPLY9U4dRrQSytS7+4553ef7RHis=; b=a5FhvHPSnbz49vwvqN6tg0HjcRVazxSCvzlxcb2fT5PfmNhJ01yiF/0YSJE9araXze g/JrrvOAHvsGA5RM7weOKqHY8eSwUN8vC/wSp4soJJJusOWVYvqlL7JvRoqfvFZiAVSM hxgK02WJa2TsSXm5ohzqopiTnj9wSxjL5qQUVC8FsEDk5ydc4MlSd+32NILb0tAPiBlT ULFOwAJGZlqaWETvzWI1QnkXqkenbUEhD7+sgauJxS9+NusEugSzburpKDpeStb+CE+1 SMTUQCJos1KABaGitA0Humma4cGqqQunPMmxsDIE9xFX/NCvXUaJVdRWv4K2MZ3NP5p7 SCBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+FYvvrpeRy/LpnKiPLY9U4dRrQSytS7+4553ef7RHis=; b=LEo9iI92Frapdjg4mz0foaJ+t007w9sWtaI+U9qADDDqKIQJTtB5+kUoYfvd3BbvjC NC8ZywYKwNn0lJbpkac5MakK6E8P/a9PgoYRGa8O0xJGAwlcacP/FnUg9TPJuocXx5GU giE++DlZM47JvGSllNixYBvg5YTH0rgrIOETZH0b41yG0Pneaxh7TKE2/KdOf26X3uCo f903qy1OWKaUTrwlkayvPNBlJrlzyt+taXwLaj53vmuLC9O67lR2tbrJtKGDEF4LTUq/ 8o0MivI2Qu4nJqfnN1ldmGxbrf7fDNGy/Jbb5rmV28IQkeSUyTEcQIQJe8gEz8p9sD4H REtQ== X-Gm-Message-State: AGi0PuaMwxb0SWlm2047rxiQyoT27y/eWwIFaqNtD6iERqFInlTxTu/U Q5N8+s8Pk/A7uDs2+wJ3ql2h5g== X-Google-Smtp-Source: APiQypLf9BTLqA40ujGrcRWGd9c0MJ5tOnig9BWpiNQKtirkJXY5Lntam7VSivb9V+yA0gJ3Fc1r3g== X-Received: by 2002:a1c:bc02:: with SMTP id m2mr1485187wmf.60.1586894804495; Tue, 14 Apr 2020 13:06:44 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 08/17] configure: disable PIE for Windows builds Date: Tue, 14 Apr 2020 21:06:22 +0100 Message-Id: <20200414200631.12799-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bug 1871798 <1871798@bugs.launchpad.net>, Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , James Le Cuirot , Howard Spoelstra , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) It seems on some compilers the test can pass but still give you broken binaries. Fixes: d2cd29e30736 Fixes: https://bugs.launchpad.net/qemu/+bug/1871798 Cc: Bug 1871798 <1871798@bugs.launchpad.net> Signed-off-by: Alex Benn=C3=A9e Tested-by: Howard Spoelstra Tested-by: James Le Cuirot Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 25f7d915720..23b5e93752b 100755 --- a/configure +++ b/configure @@ -807,6 +807,7 @@ MINGW32*) audio_drv_list=3D"" fi supported_os=3D"yes" + pie=3D"no" ;; GNU/kFreeBSD) bsd=3D"yes" --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586894973; cv=none; d=zohomail.com; s=zohoarc; b=JDaOuwJm5ZCkgwq9X/Lqqb5GXNa7cETSSs4AwxXXsfVJ569FTgrXxl4guDdZ6S8DVFQ+z7T8FWmJtCWs3jtefIbLUqof+szzWefIgLuct/xxzLJSud+VllOkYh9h4exDu9rQyxryBWsHE5qNgqUWv9470WACMrGrIzz6tfctutw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586894973; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9Tb6fI3tVBkHUd/y7Zo+dSFehRr8QpWy7fD+f4ic+ig=; b=ZOG2fMhPeC3/aBfc7gPsvr1kQaKilyRkwASXKHbgtbxzPFWjACgjjl70EmHfyMk+SHMjLQAHUwiTs6I+aS1dMmG46MdO35XeH0XHfXkJZM7cyLq603Op772IkqXfmPZ1xLchYJsr1hkzoKHPzZCLgLF0m/80uD6K76UWiwqkBe4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158689497373266.05394473456056; Tue, 14 Apr 2020 13:09:33 -0700 (PDT) Received: from localhost ([::1]:38404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORsC-0002sx-FO for importer@patchew.org; Tue, 14 Apr 2020 16:09:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44564) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpa-0006BS-1h for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpY-0005z4-Ts for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:49 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:36153) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpY-0005yf-N6 for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:48 -0400 Received: by mail-wr1-x441.google.com with SMTP id u13so15521559wrp.3 for ; Tue, 14 Apr 2020 13:06:48 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id p10sm19781721wrm.6.2020.04.14.13.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 080751FF98; Tue, 14 Apr 2020 21:06:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9Tb6fI3tVBkHUd/y7Zo+dSFehRr8QpWy7fD+f4ic+ig=; b=wttuBit2rudWSw4TCjpzebO7LSNobJFxOG3lmzE6092o9UW39mKyyA6MWVc90M9t41 gu/bsMymQ+RVAyJXqyb6BqIs1JzECzshdqlSo/EmFdM4Ktbt2H+Rjsp4DEWFCmFN92oB ko3wIVlQ/dMRRK7/eu0RN77b6UJVAkG3lWOw5vdZoQw6umLE41FaHlzcAstlCnNmzHw0 w7jjfu1L4gHmZMXgaAzRxuh+z+RcCRxV0sagbb9WhsbwxkQRrDi/8/xhE5dn71aD3gKj 2jWlZCoqYdoMfCXUiHWYPOglrUxB7EnQziqIhglIUuEJYz+zDhlc/IIAa/eP91eG6ill N8VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9Tb6fI3tVBkHUd/y7Zo+dSFehRr8QpWy7fD+f4ic+ig=; b=Ul21illD1mxwBWhwW3606Pm14XDCGxjhdGB59kB5F1TjwbOcBdVXh4aItD2Ke0cXbD kNQzt7T2uDlINqp1uGStNlZNcdAob14oS5kdwjP0DBomeQ9ykpaq+PjBbcQh6sVFKrFH HqqcT8yKw4Ht0ZOUnmp+N+REhniInN6UH/4+QjlPFA97N9MqOheOQDdBizAYXLjwLjpI 18jQzUFyHx64HtvXFt3ZR5sp4BXxZ+nMbUcaVwKzOuq+IOhquvf5K6J4yXm2tGeJI7sx WihOJvmcOnBhQYN3iWbfxURyCJ7iSQBcuOchBQKCjLIqa7dqmgR21PFRUw4oFv48kMmP ogjg== X-Gm-Message-State: AGi0Pub28TF2PuOgtzmX5HaaQQNzIikMiIIbVMBkCjpbm7qG788kKcu4 9oaLUHUEIjj51nO56CavYF5l/w== X-Google-Smtp-Source: APiQypKU7C6T7b6gLBurE2JOwtMJvkUCdMbRhOA91cw7SxtWF2+8cC5BDBrRlJysRtPjM++8Srs6gQ== X-Received: by 2002:adf:d087:: with SMTP id y7mr4275303wrh.321.1586894807624; Tue, 14 Apr 2020 13:06:47 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 09/17] linux-user: fix /proc/self/stat handling Date: Tue, 14 Apr 2020 21:06:23 +0100 Message-Id: <20200414200631.12799-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Riku Voipio , Richard Henderson , Laurent Vivier , Brice Goglin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) In the original bug report long files names in Guix caused /proc/self/stat be truncated without the trailing ") " as specified in proc manpage which says: (2) comm %s The filename of the executable, in parentheses. This is visible whether or not the executable is swapped out. In the kernel this is currently done by do_task_stat calling proc_task_name() which uses a structure limited by TASK_COMM_LEN (16). Additionally it should only be reporting the executable name rather than the full path. Fix both these failings while cleaning up the code to use GString to build up the reported values. As the whole function is cleaned up also adjust the white space to the current coding style. Message-ID: Reported-by: Brice Goglin Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- linux-user/syscall.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6495ddc4cda..674f70e70a5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7295,34 +7295,29 @@ static int open_self_stat(void *cpu_env, int fd) { CPUState *cpu =3D env_cpu((CPUArchState *)cpu_env); TaskState *ts =3D cpu->opaque; - abi_ulong start_stack =3D ts->info->start_stack; + g_autoptr(GString) buf =3D g_string_new(NULL); int i; =20 for (i =3D 0; i < 44; i++) { - char buf[128]; - int len; - uint64_t val =3D 0; - - if (i =3D=3D 0) { - /* pid */ - val =3D getpid(); - snprintf(buf, sizeof(buf), "%"PRId64 " ", val); - } else if (i =3D=3D 1) { - /* app name */ - snprintf(buf, sizeof(buf), "(%s) ", ts->bprm->argv[0]); - } else if (i =3D=3D 27) { - /* stack bottom */ - val =3D start_stack; - snprintf(buf, sizeof(buf), "%"PRId64 " ", val); - } else { - /* for the rest, there is MasterCard */ - snprintf(buf, sizeof(buf), "0%c", i =3D=3D 43 ? '\n' : ' '); - } + if (i =3D=3D 0) { + /* pid */ + g_string_printf(buf, FMT_pid " ", getpid()); + } else if (i =3D=3D 1) { + /* app name */ + gchar *bin =3D g_strrstr(ts->bprm->argv[0], "/"); + bin =3D bin ? bin + 1 : ts->bprm->argv[0]; + g_string_printf(buf, "(%.15s) ", bin); + } else if (i =3D=3D 27) { + /* stack bottom */ + g_string_printf(buf, TARGET_ABI_FMT_ld " ", ts->info->start_st= ack); + } else { + /* for the rest, there is MasterCard */ + g_string_printf(buf, "0%c", i =3D=3D 43 ? '\n' : ' '); + } =20 - len =3D strlen(buf); - if (write(fd, buf, len) !=3D len) { - return -1; - } + if (write(fd, buf->str, buf->len) !=3D buf->len) { + return -1; + } } =20 return 0; --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586894974; cv=none; d=zohomail.com; s=zohoarc; b=GfgNHlptVti2KJ+vgCJp4A4eQ7tjySGIgBYlSWXPajdSSOCwKJ3alOITo4ZTklN2DtSpTypiNjd4WNur61bCTEJTA50GATT2JlDej14RlZqTyPd52HoHIkDOape+40gyFQO79NKIo/UkZGMhJSoEntbhXoCRf1KKRFC+PqgBrgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586894974; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+h4qF34NYYCpNnzawIFaWBfnQi1AWYOeOfS8Oq1wtAU=; b=Ziiwq3UXhyM5oISGxBSlfSe+rlwy0S9Vjlib2yGV3tDN1cHP6ZJfDkVO9njkQycMZVy36m7OgF7ZeaPFLHMYQoWXr4u0lw2nQ1QprjF1xOBGh16XhroDMaLMFuc573zji5oSvSYkVW0IjWvdO8PetBqKK37ksxH7WpyufP+7CIo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586894974761122.20498645548992; Tue, 14 Apr 2020 13:09:34 -0700 (PDT) Received: from localhost ([::1]:38408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORsD-0002vn-FW for importer@patchew.org; Tue, 14 Apr 2020 16:09:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44595) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpe-0006Et-UW for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpd-00061w-Si for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:54 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:33193) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpc-0005zw-Dx for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:53 -0400 Received: by mail-wr1-x42c.google.com with SMTP id a25so16027305wrd.0 for ; Tue, 14 Apr 2020 13:06:51 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u16sm20153720wro.23.2020.04.14.13.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2ABF91FF99; Tue, 14 Apr 2020 21:06:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+h4qF34NYYCpNnzawIFaWBfnQi1AWYOeOfS8Oq1wtAU=; b=f1fjPHNHeO6rBOZGjTKY+PgSL6eLEcjGILOtdR0k3GHYzmpRjCOh56QA1C7sSz2pue KR8STw3ri3yZp/eM9FKs88g/KYL8FLhqckZFTcKsKRM04Dj2u4Ts5Vbg4CtVdgTqYFcn q6xQiKgP8wuSWcBV3gZ2u6sebhhFi2iRH2u48a2z1At46fwxCCZw2nH6+tOu/v+jSskn gLLyY77aOeZ2Tk0atiBGxUJ1hp6o92LLgEZEHL48ta9+MRdMDAyemjh31r7kXCR1JBm5 uXgtI0+y3WjVPKEGuLCHKaIYuZ8h6rjMxlVnnwmcvTeD43GhuKLna+mAPPQId3FYCLmL SS7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+h4qF34NYYCpNnzawIFaWBfnQi1AWYOeOfS8Oq1wtAU=; b=dAGujLH3RMEimKKgiTI9F+c9b1nLyqST/8ibTcjEyvPhHa1x6h93b0EtZnGQ89aFqf eaePwtZMcOfvu7FJStuQikkkNZaT0MwSy1swXl+krPEvlM43aHZGPvnQ1nksIOUnR/Tg UqPnoIqIRNM3oM6KjurLyhZBoRvIsnpElORUpFBTn4fYjlCJg569u0HjoAhPmL3QmUEx zkUwyvY0BZj9tY6Jdag5JV6c697WaYQ2eRqq8jisLvFlY/2XUQVLyl+lwRgaogKW7Jvc zZuTQtKr7Edz3dDW8khJqr1wblENdMFsNJcmYWm6sJ8+PtMyvz5M7qIyWco1Atky8PG5 jMZQ== X-Gm-Message-State: AGi0PuaLNYgJuzslCErzhduOqvNIw08Z4foiPYRIE+L7St5ncC4URqBz UJOFTJiZMG3AlefSik3qwoFg2A== X-Google-Smtp-Source: APiQypLDiCfPB4TYG7QMiIPHjlE7HT/ubIv6aqH93MebQMXgr2VQ+qxSPmw9IfDvZiRLUs6F9z1vMg== X-Received: by 2002:adf:82b1:: with SMTP id 46mr18098277wrc.44.1586894810142; Tue, 14 Apr 2020 13:06:50 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 10/17] target/m68k/helper: Fix m68k_fpu_gdb_get_reg() use of GByteArray Date: Tue, 14 Apr 2020 21:06:24 +0100 Message-Id: <20200414200631.12799-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Since a010bdbe719 the gdbstub API takes a GByteArray*. Unfortunately we forgot to update the gdb_get_reg*() calls. Do it now. Fixes: a010bdbe719 ("extend GByteArray to read register helpers") Reported-by: Peter Xu Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Vivier Reviewed-by: Peter Xu Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Message-Id: <20200409172509.4078-1-philmd@redhat.com> --- target/m68k/helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 014657c6372..cad40838956 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -109,8 +109,8 @@ static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GByt= eArray *mem_buf, int n) { if (n < 8) { int len =3D gdb_get_reg16(mem_buf, env->fregs[n].l.upper); - len +=3D gdb_get_reg16(mem_buf + len, 0); - len +=3D gdb_get_reg64(mem_buf + len, env->fregs[n].l.lower); + len +=3D gdb_get_reg16(mem_buf, 0); + len +=3D gdb_get_reg64(mem_buf, env->fregs[n].l.lower); return len; } switch (n) { --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586895329; cv=none; d=zohomail.com; s=zohoarc; b=K7Xc+u7mmqr/GsaHEHOI6FwtHwpd0hE/lgN4Qu2PtfS0IwG89X1+GJNawE+bVO5/SB+dYpbrdTxWUaXWuygwHtIh0L/y3dD03INrf4AySk62i3xCq9UY8JLTmeu+X04ha9GWMkVgb0LRxxsU5rI5VbKdURSNAziKsCijHkFxpe8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586895329; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bPwQhRdvGibSgM9jwxm8brESu2WKcPxrBlyVkpOMlqE=; b=mE8Pf7JjWVWZ0Ks6Lbt2/6IbM3WFFc5gWFjarkOCHq/O5GZx4GVBMx1NYvAV/N9nRrz8PHbTKcO0ta/TpSGVk9i9qSfT+GXYeihBysp8+BZG5uvZXEWHDG3iM0omwZWZd2wecyOvWxBVy/uZjwTeVILpUvAL3Yrwu0/928uS28w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586895329020830.371701484237; Tue, 14 Apr 2020 13:15:29 -0700 (PDT) Received: from localhost ([::1]:38526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORxv-00027Z-Gw for importer@patchew.org; Tue, 14 Apr 2020 16:15:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44578) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpd-0006CK-LK for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpa-0005zn-4N for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:52 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:38787) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpZ-0005zK-UZ for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:50 -0400 Received: by mail-wm1-x32e.google.com with SMTP id g12so7907648wmh.3 for ; Tue, 14 Apr 2020 13:06:49 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a205sm15483375wmh.29.2020.04.14.13.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 585D81FF9A; Tue, 14 Apr 2020 21:06:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bPwQhRdvGibSgM9jwxm8brESu2WKcPxrBlyVkpOMlqE=; b=ZHs6+T8P2V4NE5qGEv4Tz+U6rxgh9AG50KbjQDc/JCEXQbcKQXxH74p/9wXdbq8m3T FJqr+Ntsr+W9Wp1O/3HZMOkrHunP0sjl97W0fX9FqMQpNKgc7ikz2v5Jp1NScH1JHb6K mI/gYrdv4geJ/PKpUiF0A5uIGp5esL/iKB5aFfBYFJH0Ntm9hdyRGns69F84B8yK0Uj7 00eGNVDPH0/8avgkOUI3SWrQPvAuDwfqQ9kxAe2rcHWCy2w9WxCzWyPKGul2+vo/SYhN nwzez2xyveo79KiD+9qkXK+s+R9qDILnrHhQAOiub5u1K+BCtzvu3THlwhz4GTGRVW4C xPYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bPwQhRdvGibSgM9jwxm8brESu2WKcPxrBlyVkpOMlqE=; b=RPT2sncdYeHZO10O0lwzXZNKrOcQau1d5c04GHq6M29x3pfQAsamp3ZOaXpuFNXASZ EC8tcDR0hMUs3ZVVT4RP+zSkuet8R18Ca28dhO0RzLEK4hZy3wTrDVbiD2BkyCQoA/i/ GKI9eKHx3QG0l/cUWoyrssLVPSlQ7OrtVO+Zrb3gtJlV7ar2Vm080Co7pzT7iScIMIY4 0Ow0ugLnYI+ARjijs36KOk6a2ilQvJf4rcz9oTmzoWnIOpo3Bvcby8bg0NepRmQrh9lX ncQIrKGiuxWhxj8dLr+qaEAJo3YopK4sWAgJ63o7hVFby05zrBJj7zelCFfz2QCetOZM GiNA== X-Gm-Message-State: AGi0PuYGa/q6TuWH0CVyDHxXE8bs1J9iwoE+j+B6pwutREiK29MJ8zlB d9vdpZSRWTQcAd49wL4T6nqW5A== X-Google-Smtp-Source: APiQypLF+7Hb1JbiLgu9Jecullk+r5OV6x3N5GcjwrmnSqmSUtLByTYR1yMftF30io3ddg9Gnnyc6A== X-Received: by 2002:a1c:dfc2:: with SMTP id w185mr1427740wmg.1.1586894808896; Tue, 14 Apr 2020 13:06:48 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 11/17] gdbstub: i386: Fix gdb_get_reg16() parameter to unbreak gdb Date: Tue, 14 Apr 2020 21:06:25 +0100 Message-Id: <20200414200631.12799-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32e X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Peter Xu , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Peter Xu We should only pass in gdb_get_reg16() with the GByteArray* object itself, no need to shift. Without this patch, gdb remote attach will crash QEMU: (gdb) target remote :1234 Remote debugging using :1234 Remote communication error. Target disconnected.: Connection reset by pe= er. $ qemu-system-x86_64 -m 1G -smp 4 ... -s ERROR:qemu/gdbstub.c:1843:handle_read_all_regs: assertion failed: (len = =3D=3D gdbserver_state.mem_buf->len) Bail out! ERROR:qemu/gdbstub.c:1843:handle_read_all_regs: assertion faile= d: (len =3D=3D gdbserver_state.mem_buf->len) Fixes: a010bdbe719 ("extend GByteArray to read register helpers") Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Tested-by: Stefano Garzarella Reviewed-by: Richard Henderson Message-Id: <20200409164954.36902-3-peterx@redhat.com> --- v2 - tags and expand comment --- target/i386/gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index f3d23b614ee..b98a99500ae 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -106,7 +106,7 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray = *mem_buf, int n) } else if (n >=3D IDX_FP_REGS && n < IDX_FP_REGS + 8) { floatx80 *fp =3D (floatx80 *) &env->fpregs[n - IDX_FP_REGS]; int len =3D gdb_get_reg64(mem_buf, cpu_to_le64(fp->low)); - len +=3D gdb_get_reg16(mem_buf + len, cpu_to_le16(fp->high)); + len +=3D gdb_get_reg16(mem_buf, cpu_to_le16(fp->high)); return len; } else if (n >=3D IDX_XMM_REGS && n < IDX_XMM_REGS + CPU_NB_REGS) { n -=3D IDX_XMM_REGS; --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586895068; cv=none; d=zohomail.com; s=zohoarc; b=U/UwnMwQtw0OZTSnzLaRDKxEhSL4vOS/noXxMxoNUoUHSmqFX+8Fy+Z2OU2n9Qo2bp4/YId3lJRYr4NX22E6mCPRYtn7d9fKJrH33XkEhBjri5aJRjBw9FCPfkn8ZIM2j0BTF8g1xQTWkOd3DA0FZHClj2rKBYjtI0K0xP/cwRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586895068; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aZ6FKx87IIsaQ+fv9HHif36FthP5pDUoqk2AxtvgmQ8=; b=GrM4xJKkGzBWBZ3aV6hOOb1nP66C5tY4Gm8cwD5TJQIeUVZ5AjOU1WCxJtmcPBEYXCKB56LAiInTd7uzFSGDVA2MnJeIpA2rqFn5BRqQ734obc0MjVPFfkj+0Y3MmhksBbO2x1WwdssBlAmDZaCmjxC2DfA7BOEEmrWury6iblY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586895067986665.2086312458765; Tue, 14 Apr 2020 13:11:07 -0700 (PDT) Received: from localhost ([::1]:38458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORti-0005xZ-Pa for importer@patchew.org; Tue, 14 Apr 2020 16:11:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44542) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpY-0006Ag-OG for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpX-0005yQ-JD for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:48 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:54470) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpX-0005xz-CK for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:47 -0400 Received: by mail-wm1-x332.google.com with SMTP id h2so14492110wmb.4 for ; Tue, 14 Apr 2020 13:06:47 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q17sm11836553wmj.45.2020.04.14.13.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 87CFB1FF9B; Tue, 14 Apr 2020 21:06:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aZ6FKx87IIsaQ+fv9HHif36FthP5pDUoqk2AxtvgmQ8=; b=eUXplBNYodG6JvFBONo8L2tEaI/kp6eZoywXUqbyebmAcDcuCDcAeR0YJYW95D5TaH 0RNJJwZpd3ggMQ/YHnfJGW72P1lZk0wVjw7RWju1wmk/LB2XZtag/CxNHYbBpDDcqYyq 1hlP7oX7jJxTMPnELJTdLeg3hkiyyFtsBeuttFJT5tuIk86jyxkVhgNjv4saKw+uRsfn F007fJBxomr6EKdpnxoRpIjjnAmQsOFKEaU3/lnOR8p3lGjven6DckXymUNTdqDz610z 8X35a5na7Rav/ANxVFULQgDnsw55VRFt6+KfllhSogx72uBa5fR3gbQT4JDnxlwfCOh9 t6bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aZ6FKx87IIsaQ+fv9HHif36FthP5pDUoqk2AxtvgmQ8=; b=b4NDhEZnHBO25iBElobheZm0ggRpAlM3SfUIc+cfwznOI3LrwRmqyPacr/z+TuZ3wO t8/eE304Ko2g4jyabb3bYna+AVHayChut/9+f75cARVYelQBnYv1hyf5JV8ee6PnGTvH bAp6OwVz+zDrMmRuLkXQeTkVWqFLbCl3egta08p0tYpE7UB9gOLSuQQXDjhCUU0W4DIZ P6GwhXLSutLcGstW13xPUR/u93H0hhkPRLitBMrfmQ6SXpnx66uK4q0dGjkouh8GV3/p sxebk5xG2aOlZS+wBwsaxMPb1GbFHIntt3J0+9fDjbrxWOp8kOwHEoGtXbkz2m9uvUrj 2K+Q== X-Gm-Message-State: AGi0PuZsTXPUut4DWGqYFi4Yd49f6TUlcejK1C/S9F+azTfQDkDU/6Rw mI1erRPgPfaUuce1sMuwc2PKOQ== X-Google-Smtp-Source: APiQypIjq+bOv/fD6Tg0a0tqQj+Pv+Ssu1MFdXasDH/p9VfEpXuxFlYElcFgMoNkUfcyGdzr9yZeBg== X-Received: by 2002:a1c:4b0a:: with SMTP id y10mr1472289wma.24.1586894806418; Tue, 14 Apr 2020 13:06:46 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 12/17] gdbstub: Do not use memset() on GByteArray Date: Tue, 14 Apr 2020 21:06:26 +0100 Message-Id: <20200414200631.12799-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "open list:ARM TCG CPUs" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Introduce gdb_get_zeroes() to fill a GByteArray with zeroes. Fixes: a010bdbe719 ("extend GByteArray to read register helpers") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200414102427.7459-1-philmd@redhat.com> [AJB: used slightly more gliby set_size approach] Signed-off-by: Alex Benn=C3=A9e --- include/exec/gdbstub.h | 9 +++++++++ target/arm/gdbstub.c | 3 +-- target/xtensa/gdbstub.c | 6 ++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 30b909ebd27..3c452fc50c0 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -125,6 +125,15 @@ static inline int gdb_get_reg128(GByteArray *buf, uint= 64_t val_hi, return 16; } =20 +static inline int gdb_get_zeroes(GByteArray *array, size_t len) +{ + guint oldlen =3D array->len; + g_byte_array_set_size(array, oldlen + len); + memset(array->data + oldlen, 0, len); + + return len; +} + /** * gdb_get_reg_ptr: get pointer to start of last element * @len: length of element diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 8efc535f2a0..063551df234 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -47,8 +47,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *m= em_buf, int n) if (gdb_has_xml) { return 0; } - memset(mem_buf, 0, 12); - return 12; + return gdb_get_zeroes(mem_buf, 12); } switch (n) { case 24: diff --git a/target/xtensa/gdbstub.c b/target/xtensa/gdbstub.c index 0ee3feabe54..4d43f1340ae 100644 --- a/target/xtensa/gdbstub.c +++ b/target/xtensa/gdbstub.c @@ -105,8 +105,7 @@ int xtensa_cpu_gdb_read_register(CPUState *cs, GByteArr= ay *mem_buf, int n) default: qemu_log_mask(LOG_UNIMP, "%s from reg %d of unsupported size %= d\n", __func__, n, reg->size); - memset(mem_buf, 0, reg->size); - return reg->size; + return gdb_get_zeroes(mem_buf, reg->size); } =20 case xtRegisterTypeWindow: /*a*/ @@ -115,8 +114,7 @@ int xtensa_cpu_gdb_read_register(CPUState *cs, GByteArr= ay *mem_buf, int n) default: qemu_log_mask(LOG_UNIMP, "%s from reg %d of unsupported type %d\n", __func__, n, reg->type); - memset(mem_buf, 0, reg->size); - return reg->size; + return gdb_get_zeroes(mem_buf, reg->size); } } =20 --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586895442; cv=none; d=zohomail.com; s=zohoarc; b=Y2wBfUgtKSE46Enxl8G0mvvXL3NoitSUrQJ6Wu5B2+7Q/tT/0y/DiZnWBLArn0FKdVwqEwG/E3BL/wyjDFw/GECC2M8jz/Aop/1RDcIFDWqCqKrPh1dG1Bc9aJiCj9BKFNCRc4NflvHIjQO5n4PHE7GfBR1pJRes3fNEvcQywME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586895442; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y41oariPSirC8NfMhDAA8Vm62k5I1+y4ZRfI3cHl76k=; b=bKjX1UtMCteLpSlN3dd8xx7zZLTfoX24UqmofFspffkvbefbvN41qbR8xwgysG77aKH0o6sBN3LgHQavui4Xf2/VEjqwwQvnV7ouoBlLtpGxxPEUzYbpJWTRGXAacPGH1ftueH9lMttq4ZACXURXAH4e0+H9owvoT5kYahQ2N0Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586895442523354.2685464694415; Tue, 14 Apr 2020 13:17:22 -0700 (PDT) Received: from localhost ([::1]:38603 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORzl-000591-8O for importer@patchew.org; Tue, 14 Apr 2020 16:17:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44597) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORpf-0006Eu-4b for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORpe-000627-3a for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:55 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:44212) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORpd-00060K-Rk for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:06:54 -0400 Received: by mail-wr1-x42f.google.com with SMTP id d17so9089172wrg.11 for ; Tue, 14 Apr 2020 13:06:52 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id t2sm13394364wmt.15.2020.04.14.13.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:06:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AF3781FF7E; Tue, 14 Apr 2020 21:06:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y41oariPSirC8NfMhDAA8Vm62k5I1+y4ZRfI3cHl76k=; b=YgfGVdkf//l7U+mJ+B5Z6iAPJUBTw6O2mNuPpXLZEA29xfYTZ+OcqUyigRwqEXLUAD YZRUmM9/fbl1DhPgfD+pYoX7x0TErvieLRGlVhJtOtj9HAmu7lDtILdp9Fh907bqD2wT 11VaE4LcsxutGRAEp38Z1BooO4y9oky49ENLw8OuIaGPtwYdyCqGFVjXlIlsvvKCC/EG jHUZOTe1KPGA/3Z932uOpZ+wYNScmq40cDeIc5wBo/Q6fEE0gfzXhbV6+PSOdUD99p40 E7fi9Yf5NwHkZs7TpneG5q6UWNuJKxSrounIi5KfAkhNMjC2xhJsVpNoLftZjJJZ5SJI jyAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y41oariPSirC8NfMhDAA8Vm62k5I1+y4ZRfI3cHl76k=; b=hnTnRle6ADKvp5C5X+bDM3Lt3xBH99pv/vyEjLeWE9nBDFozrhD9tTv8oIhKeSVj5T a1RljSqVEeELlY8gFwUJ/6wxQQmNh1GOyEbCbgXRzHQkM7DeV/2oFL6eZeJ1TtrMtM8O VqEXP/zPijHQO52u1xeb3FDzaOaCheCeGHHtei31QpbUQmoAal1C9JPuPyDOihPIQaUu kCVSC6GJBFQ0TmvO1JF+FlBUyQOMC0HXW1gOOJfNxuN1HDyB78NLARlDlTgZNo6gxOiL 2bDlu8ZvHfUNgtUAAIa/9ipIhfX0RH4fZ7XAABqjm9TXLIJh9pBQzls2vF4mgawJpk43 6MtA== X-Gm-Message-State: AGi0PuZtOMiEliouCXdHYd8QykeL0YalrB1L9ExRcLaPZfJD0tO9ebGZ K+DZ0JTiDPkVbg3uSMnP80hEZQ== X-Google-Smtp-Source: APiQypLBaw01LLop1TDT5c0qnMI0OJY0cAm90MBqKOcrEawitZ0lNg8aHw82UCgVTA5KyTRke0m5XA== X-Received: by 2002:a5d:4a42:: with SMTP id v2mr24248547wrs.333.1586894811402; Tue, 14 Apr 2020 13:06:51 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 13/17] gdbstub: Introduce gdb_get_float32() to get 32-bit float registers Date: Tue, 14 Apr 2020 21:06:27 +0100 Message-Id: <20200414200631.12799-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Since we now use a GByteArray, we can not use stfl_p() directly. Introduce the gdb_get_float32() helper to load a float32 register. Fixes: a010bdbe719 ("extend GByteArray to read register helpers") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20200414163853.12164-2-philmd@redhat.com> Reviewed-by: Richard Henderson --- include/exec/gdbstub.h | 9 +++++++++ target/sh4/gdbstub.c | 6 ++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 3c452fc50c0..20e10726929 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -125,6 +125,15 @@ static inline int gdb_get_reg128(GByteArray *buf, uint= 64_t val_hi, return 16; } =20 +static inline int gdb_get_float32(GByteArray *array, float32 val) +{ + uint8_t buf[sizeof(CPU_FloatU)]; + + stfl_p(buf, val); + g_byte_array_append(array, buf, sizeof(buf)); + + return sizeof(buf); +} static inline int gdb_get_zeroes(GByteArray *array, size_t len) { guint oldlen =3D array->len; diff --git a/target/sh4/gdbstub.c b/target/sh4/gdbstub.c index 49fc4a0cc69..34ad3ca0508 100644 --- a/target/sh4/gdbstub.c +++ b/target/sh4/gdbstub.c @@ -58,11 +58,9 @@ int superh_cpu_gdb_read_register(CPUState *cs, GByteArra= y *mem_buf, int n) return gdb_get_regl(mem_buf, env->fpscr); case 25 ... 40: if (env->fpscr & FPSCR_FR) { - stfl_p(mem_buf, env->fregs[n - 9]); - } else { - stfl_p(mem_buf, env->fregs[n - 25]); + return gdb_get_float32(mem_buf, env->fregs[n - 9]); } - return 4; + return gdb_get_float32(mem_buf, env->fregs[n - 25]); case 41: return gdb_get_regl(mem_buf, env->ssr); case 42: --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586895812; cv=none; d=zohomail.com; s=zohoarc; b=NimgN98MP942YoVn3SMMhXX0qpqrDI73Ip0wI6WIMmnkw1x0qOr8D9wezCFIBde///720FtU3uDvEhY57dN2NSWJYojDqsV8ipF6HQWtkS1PfrN8NPWw+LLX3dNcPxXSQW6w4Tzx2AwaeG+pl+YEQ0pyZhYJipJZC5x3/1Z8pqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586895812; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3UWknvv+wdPtsXv26OjYUAVxV8/wuy9nynu7HohmC0w=; b=gw3n7gkMTPzgP5rZ3DNdLCbo+dFPgDVReYeT3WXookSWyOGOynbj3iJcKWFfa3C/hiwLRFrPEiCM0i9Ba3/MilI2hG0uq5A/x0XpZoFkiLjtmSo3slCJKrN7bW1o/jk/1l+fz85Oxz99Hq+lmuKCbxH2BM8A8HWl0gnQActqDyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586895812245925.1893103624234; Tue, 14 Apr 2020 13:23:32 -0700 (PDT) Received: from localhost ([::1]:38726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOS5j-0004Af-0T for importer@patchew.org; Tue, 14 Apr 2020 16:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45924) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORyj-00042g-IN for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORyi-0001jM-Bh for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:17 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:52681) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORyi-0001ik-4v for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:16 -0400 Received: by mail-wm1-x332.google.com with SMTP id o81so8958236wmo.2 for ; Tue, 14 Apr 2020 13:16:16 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id i17sm20105226wml.23.2020.04.14.13.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:16:11 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DACC01FF9C; Tue, 14 Apr 2020 21:06:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3UWknvv+wdPtsXv26OjYUAVxV8/wuy9nynu7HohmC0w=; b=PHCviFKd1hV0AsvNdCAwXWgDWrWM8XIaHkCpvzTa5wp7ih6mgcaiHoPqewJfOuTfZ6 hEaLhALhRKBTz7k7/fUtV0M9spzMOFsZX7Z99FZqjk8MXz2BLEmlxXsiOkG4zZ92PE19 9BAnhPz+Gl7JQzcvpN+L130pii2DI3n+650ZBJuQNs0c5NMh27xx+NyFyRHqjbF3qCqT dPESQiY4+5DSxxYXxrz20457bN+wmGMFLTCMv+jIKc9uB61Xb5bGHrZXcnMv0ULw9Oir 7yH/LpSYiVNr/Inl2leKT6137CRB9VSP2HmXOylEpsDwyN1IONMI8MNRPtjw4/OWGf5Z bapA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3UWknvv+wdPtsXv26OjYUAVxV8/wuy9nynu7HohmC0w=; b=rlxYTXdqmNucbYGxyvVouLUaLkNC1LSeG4MNGTg+EdrBzGhZp78JmSGq4W++wJoUSr jQ2bLQdl3z1oFfNJWIvmgMQTES3K0Ez9X0+QKeDqvle0orn1he3FTZST/o6SS5qLwU6+ QDTCPNLW0834cbXY0rRUeOgh6dh2GpCWaHT23f/x8tRzqXEID+91BywMLir+lSm2v0ZX WBEJELo3PWotsnkZ65zmS5zCEXzbZD2hQHgaZy6CkdMBLWloCjThfY4OHxSKOdu7a3rJ yyjXo8uurfIPczzNnzDlYE239hGKYib59FYR+ACpN/zUS8P7LmaVBZ6IDogfbp4+7ob9 SLUg== X-Gm-Message-State: AGi0PuZWmzedRMOVpYLDD8Iv0+7dZfrWOoqgeX+nFlZwtvK7Bc1oIzKa qISV3eU9qkVpvn6DrfV6fQra5w== X-Google-Smtp-Source: APiQypKds5eoCFqOquXQCPI4q19JvTqtESrBQKB4hPpDuygqNFQggIaDC33aw78B+WQpHaQZl1WX/g== X-Received: by 2002:a05:600c:2112:: with SMTP id u18mr1627424wml.112.1586895375103; Tue, 14 Apr 2020 13:16:15 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 14/17] gdbstub: Introduce gdb_get_float64() to get 64-bit float registers Date: Tue, 14 Apr 2020 21:06:28 +0100 Message-Id: <20200414200631.12799-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:PowerPC TCG CPUs" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 When converted to use GByteArray in commits 462474d760c and a010bdbe719, the call to stfq_p() was removed. This call serialize a float. Since we now use a GByteArray, we can not use stfq_p() directly. Introduce the gdb_get_float64() helper to load a float64 register. Fixes: 462474d760c ("target/m68k: use gdb_get_reg helpers") Fixes: a010bdbe719 ("extend GByteArray to read register helpers") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20200414163853.12164-3-philmd@redhat.com> --- include/exec/gdbstub.h | 11 +++++++++++ target/m68k/helper.c | 3 ++- target/ppc/gdbstub.c | 4 ++-- target/ppc/translate_init.inc.c | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 20e10726929..4a2b8e30893 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -134,6 +134,17 @@ static inline int gdb_get_float32(GByteArray *array, f= loat32 val) =20 return sizeof(buf); } + +static inline int gdb_get_float64(GByteArray *array, float64 val) +{ + uint8_t buf[sizeof(CPU_DoubleU)]; + + stfq_p(buf, val); + g_byte_array_append(array, buf, sizeof(buf)); + + return sizeof(buf); +} + static inline int gdb_get_zeroes(GByteArray *array, size_t len) { guint oldlen =3D array->len; diff --git a/target/m68k/helper.c b/target/m68k/helper.c index cad40838956..79b0b10ea9b 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -72,7 +72,8 @@ static int cf_fpu_gdb_get_reg(CPUM68KState *env, GByteArr= ay *mem_buf, int n) { if (n < 8) { float_status s; - return gdb_get_reg64(mem_buf, floatx80_to_float64(env->fregs[n].d,= &s)); + return gdb_get_float64(mem_buf, + floatx80_to_float64(env->fregs[n].d, &s)); } switch (n) { case 8: /* fpcontrol */ diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index eb362dd9aec..5c11c88b2a8 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -130,7 +130,7 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray = *buf, int n) gdb_get_regl(buf, env->gpr[n]); } else if (n < 64) { /* fprs */ - gdb_get_reg64(buf, *cpu_fpr_ptr(env, n - 32)); + gdb_get_float64(buf, *cpu_fpr_ptr(env, n - 32)); } else { switch (n) { case 64: @@ -184,7 +184,7 @@ int ppc_cpu_gdb_read_register_apple(CPUState *cs, GByte= Array *buf, int n) gdb_get_reg64(buf, env->gpr[n]); } else if (n < 64) { /* fprs */ - gdb_get_reg64(buf, *cpu_fpr_ptr(env, n - 32)); + gdb_get_float64(buf, *cpu_fpr_ptr(env, n - 32)); } else if (n < 96) { /* Altivec */ gdb_get_reg64(buf, n - 64); diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index e853164a865..d825cb59758 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -9881,7 +9881,7 @@ static int gdb_get_float_reg(CPUPPCState *env, GByteA= rray *buf, int n) { uint8_t *mem_buf; if (n < 32) { - gdb_get_reg64(buf, *cpu_fpr_ptr(env, n)); + gdb_get_float64(buf, *cpu_fpr_ptr(env, n)); mem_buf =3D gdb_get_reg_ptr(buf, 8); ppc_maybe_bswap_register(env, mem_buf, 8); return 8; --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586895477; cv=none; d=zohomail.com; s=zohoarc; b=np2NyctXx719fV5fHM3sjVT0xeficDx+ZT7hRyta+65T8O9bmvGx6m0xcptLoYDh1CdnfLv0A2DSQVRCmOG9/xwY0Xyma5TWueENx8sP8N+hgJ54KhYeDadOPz/Ymb+S1bjRh7ZQKrN2VqsSLWI994Ivxd92CWN6fkFgwheKpuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586895477; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=U0GHkMxjV1uSRYh2+mG4n9m1cHTJmvyky0OeonmCsaU=; b=dss4PQk9Eteokozlt2nnNxK0ng0otLS+cgJ3R5GFjmST3ABROhJ5PntMJTH0aNplJ4o9tVEbyygEdb0W3W4fGfDfA4I2VbhX0WkMSFQp4vckELROh+PY8vdOJCF+p8gbnAkD2LFnrY9SB+qoO28A8iNPkJ1aPFWQ5InZ2h1DQ6k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586895477094590.3381254243171; Tue, 14 Apr 2020 13:17:57 -0700 (PDT) Received: from localhost ([::1]:38618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOS0J-0005ta-Rg for importer@patchew.org; Tue, 14 Apr 2020 16:17:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45913) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORyi-00040S-Lm for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORyh-0001iV-BM for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:16 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:40511) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORyh-0001hw-4e for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:15 -0400 Received: by mail-wm1-x342.google.com with SMTP id a81so15773847wmf.5 for ; Tue, 14 Apr 2020 13:16:15 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id w12sm5778068wrk.56.2020.04.14.13.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:16:11 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 09FA11FF9D; Tue, 14 Apr 2020 21:06:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U0GHkMxjV1uSRYh2+mG4n9m1cHTJmvyky0OeonmCsaU=; b=zDyVX+eGLidywceNh4TJT/ZYZU5Sl8GDbcntFEUGG5+KT3G5Rp02Ky9cQbxUpfbefN MQq8fa1MP/TzuzOq3BesyNCGzQIhS1w01JPNnmjJZ/gaYLiYfTrDiDdrK0zEwNjNzbKb UWLiqqrX9WVcYop2mp08FcL3LqKt04r69IWfcx+5UyhTWHbU1PSdLKNBg5cV58rW5N6B lZiInQtKv7errpITUoT5XmBZwzKMx+hVVn1pQMCzYjD4ephmZUvxx6tTy6ZBbWWA/d+b GyB3HSD+M4CHp9CyN9p5hIUpNRTjp1d5mBC63geazmVR/BvS0Vb+v3pJh4yHWRKz4Air nnmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U0GHkMxjV1uSRYh2+mG4n9m1cHTJmvyky0OeonmCsaU=; b=UYOR36MEIJvFMh20UINTjdzggLfCzNc2Z+7P7gpyrfkB03o7TevlTjbID1KSEgkzjE IVbN+7bGd4OadXLRmshO4IT5YS464YwoG5FiMQdWzVxYulI6sNJBP3psOg8YWQ4H/HhW JPIykLsLoAssmttOwsYMAFipNRdn5twRct2nq24wlhBlOgzVxM+998PQraQshT5Pi0gw QCNnVd4rCqoTQLnIYzhX2PXhuAVU88nv1N2kDif+SVZFQSd0Q7P3MJtg00gcytR0jsKI prxI6NmbyK9ZkvFMym07DPlFdPxwA6Q5RYIwm7XbSUxp3lc369NLq4WNGYR64hREL5Wk 88Pg== X-Gm-Message-State: AGi0PubOnOG75oH9iKQRsIGqzOTCZabA10n2/VgFgC9EdhllundIqlkI +fVcvg21OK3SQ4FrBEBmnhdoYs64EUA= X-Google-Smtp-Source: APiQypKU7B+SAR0tD9up2nLR7I6A6sBWx864DeYzBvGVPvRy0iyNS2uU9KguBdQT8LI6gu1pgz73JQ== X-Received: by 2002:a1c:808c:: with SMTP id b134mr1587510wmd.131.1586895374113; Tue, 14 Apr 2020 13:16:14 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 15/17] target/m68k: hack around the FPU register support (HACK!) Date: Tue, 14 Apr 2020 21:06:29 +0100 Message-Id: <20200414200631.12799-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Attempting to attach to the gdbstub causes GDB to complain: warning: Register "fp0" has an unsupported size (80 bits) warning: Register "fp1" has an unsupported size (80 bits) warning: Register "fp2" has an unsupported size (80 bits) warning: Register "fp3" has an unsupported size (80 bits) warning: Register "fp4" has an unsupported size (80 bits) warning: Register "fp5" has an unsupported size (80 bits) warning: Register "fp6" has an unsupported size (80 bits) warning: Register "fp7" has an unsupported size (80 bits) Remote 'g' packet reply is too long (expected 148 bytes, got 164 bytes): = 000000000000000000000000000000000000000000000000000000000000000000000000000= 000000000000000000000000$ 00000000000000000000408009f000000000800003407fffffffffffffffffff7ffffffff= fffffffffff7fffffffffffffffffff7fffffffffffffffffff7fffffffffffffffffff7fff= ffffffffffffffff7fffffff$ fffffffffff7fffffffffffffffffff000000000000000000000000 and then subsequently fail. The root problem seems to be this is an undefined size register for the target description. There does exist a floatformats_m68881_ext in GDB but setting "m68881_ext" also fails as the only "weird" tdesc types gdb seems to understand are: { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT }, { "i387_ext", TDESC_TYPE_I387_EXT } So present the register as a i386_ext as some sort of hack. The values are garbage but at least we can continue to connect. Perhaps we should just delete the code because I don't think this ever worked with upstream tools. Signed-off-by: Alex Benn=C3=A9e Cc: Laurent Vivier --- target/m68k/helper.c | 11 +++++------ gdb-xml/m68k-fp.xml | 16 ++++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 79b0b10ea9b..80069adb8cc 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -109,9 +109,8 @@ static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8_= t *mem_buf, int n) static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, in= t n) { if (n < 8) { - int len =3D gdb_get_reg16(mem_buf, env->fregs[n].l.upper); - len +=3D gdb_get_reg16(mem_buf, 0); - len +=3D gdb_get_reg64(mem_buf, env->fregs[n].l.lower); + int len =3D gdb_get_reg64(mem_buf, cpu_to_le64(env->fregs[n].l.low= er)); + len +=3D gdb_get_reg16(mem_buf, cpu_to_le16(env->fregs[n].l.upper)= ); return len; } switch (n) { @@ -128,9 +127,9 @@ static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GByt= eArray *mem_buf, int n) static int m68k_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n) { if (n < 8) { - env->fregs[n].l.upper =3D lduw_be_p(mem_buf); - env->fregs[n].l.lower =3D ldq_be_p(mem_buf + 4); - return 12; + env->fregs[n].l.lower =3D le64_to_cpu(* (uint64_t *) mem_buf); + env->fregs[n].l.upper =3D le16_to_cpu(* (uint16_t *) (mem_buf + 8)= ); + return 10; } switch (n) { case 8: /* fpcontrol */ diff --git a/gdb-xml/m68k-fp.xml b/gdb-xml/m68k-fp.xml index 64290d16306..8eb55af2860 100644 --- a/gdb-xml/m68k-fp.xml +++ b/gdb-xml/m68k-fp.xml @@ -6,14 +6,14 @@ notice and this notice are preserved. --> - - - - - - - - + + + + + + + + =20 , --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586895746; cv=none; d=zohomail.com; s=zohoarc; b=Sg/hA/kfzx2stx25bDFwmIUAn/d+tEERYF0q5V9qLeInlfDJV2tAT+kmGWBQ4WU/c1rWkPubwUQ1qQi93hRCLPUBcqXHOZGnFeL7K2JgZ2Ke9XZ5fT9aKVwFvvJ6p96o66E5H7AR78FGoU7bBHKKzAEKvh7lf21XFHcLwrwyt1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586895746; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NPiyUCAjRop3t1WgPzKfTIoYlwAGqnRWW17Y8kgOmss=; b=kvLlj6T5zm2+4SGOJ/e/SOPy9K7YSKcM2tEFvdutAJFqhpyG4Z6xJkxgD0jePZeAjS7HZoVK9/NAacCzuzx+So8AbEj6cSAWYmdHC4pyuVfKGVFSN1ga/bGDPSpW1tyhLhxvDDu4qZxB20e2QAeXsuZd8eAX7InswftRjTZ5OIo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586895746223706.9412978535635; Tue, 14 Apr 2020 13:22:26 -0700 (PDT) Received: from localhost ([::1]:38700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOS4f-000340-0Z for importer@patchew.org; Tue, 14 Apr 2020 16:22:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45874) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORyh-0003xD-5O for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORyf-0001hV-RL for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:14 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:53640) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORyf-0001gg-H3 for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:13 -0400 Received: by mail-wm1-x32f.google.com with SMTP id d77so14538532wmd.3 for ; Tue, 14 Apr 2020 13:16:13 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y9sm19434556wmm.26.2020.04.14.13.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:16:11 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 31E541FF9E; Tue, 14 Apr 2020 21:06:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NPiyUCAjRop3t1WgPzKfTIoYlwAGqnRWW17Y8kgOmss=; b=v/dySJqPPNf/T7mPWN0oYESPDypKjKp5xHxSiMfxPfnUaVxMuqEsH5gzYWcLoLrxYq a3CVyLt9+uKeI1c7khVD0y/QJW+6KUYUQXLxl1ElA4SZ+8slq/cgJ9bSwsiQmDHNfNa4 oc6V9EB3gALg5DM9nzmcuTg0ZRToKyXhlAzJGqzz8byKWyMHGd7AebTuVNj0PHTdUnPU gvyFKDd/pnkoIty0RhzU7/cq6JgRpNqRwTIoZuucI996R9lzfY++cnYi+r7x7Ui1319t kZ0q9uphLiPTEIp/S9VuWNnorDCbZcV2Z2ibe9rAaV1bXnIfTF0kvj01hVjoa118ChyX 7gGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NPiyUCAjRop3t1WgPzKfTIoYlwAGqnRWW17Y8kgOmss=; b=O2sy9qvLwf1kzD8ry4R4UoOQmUwpgzQw8nc+Vg5AG0e35RRGLMOmbyXU81O5dpA2R/ ogbgzI8wFpxg3PR8sirJA0WFyfS9WmYLlZjBLbt9nzK+/W4FmGjO7wupNyQmwMCXrJGp qz4lPt3SrJRx2bMAim6omdg2RZto6YDuRVmKBS04xx3N3fU3nC5gB7kBLtLVX1vaM+Qn mz7c4rd0JzfC8RtJPGZT0ctXkprSHRJH0wSj3PtCIcybA04DbKtxGAeZNtROwpGf5ERz qLmrsPiaRzkWhTGNE0HTbpVIDXAVn0KKYeFU3W8lfO+YlI6mAbUjRcxZo7kE5cErevo1 6CQg== X-Gm-Message-State: AGi0PuZqmN/LlIBNaG5tf6+EikWD+nx3W1rhckI6/2X4kauSHRkgFFcn e6iqPULgBeZPlZm47pMq0vKwEQ== X-Google-Smtp-Source: APiQypJ8f3dtPM71hhtp8NrfIcNzbDDOJ6uPfpVUYGE98V/HxVImHARvdMCL5K1XWG/zS9h0DefQFg== X-Received: by 2002:a1c:a7c4:: with SMTP id q187mr1677166wme.56.1586895372176; Tue, 14 Apr 2020 13:16:12 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 16/17] tests/tcg: drop inferior.was_attached() test Date: Tue, 14 Apr 2020 21:06:30 +0100 Message-Id: <20200414200631.12799-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32f X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "open list:ARM TCG CPUs" , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This test seems flaky and reports attachment even when we failed to negotiate the architecture. However the fetching of the guest architecture will fail tripping up the gdb AttributeError which will trigger our early no error status exit from the test Signed-off-by: Alex Benn=C3=A9e --- tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 3 --- tests/tcg/aarch64/gdbstub/test-sve.py | 3 --- 2 files changed, 6 deletions(-) diff --git a/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py b/tests/tcg/aarch6= 4/gdbstub/test-sve-ioctl.py index 984fbeb277e..5824abe09ac 100644 --- a/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py +++ b/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py @@ -58,9 +58,6 @@ def run_test(): # try: inferior =3D gdb.selected_inferior() - if inferior.was_attached =3D=3D False: - print("SKIPPING (failed to attach)", file=3Dsys.stderr) - exit(0) arch =3D inferior.architecture() report(arch.name() =3D=3D "aarch64", "connected to aarch64") except (gdb.error, AttributeError): diff --git a/tests/tcg/aarch64/gdbstub/test-sve.py b/tests/tcg/aarch64/gdbs= tub/test-sve.py index dbe7f2aa932..90201d80094 100644 --- a/tests/tcg/aarch64/gdbstub/test-sve.py +++ b/tests/tcg/aarch64/gdbstub/test-sve.py @@ -59,9 +59,6 @@ def run_test(): # try: inferior =3D gdb.selected_inferior() - if inferior.was_attached =3D=3D False: - print("SKIPPING (failed to attach)", file=3Dsys.stderr) - exit(0) arch =3D inferior.architecture() report(arch.name() =3D=3D "aarch64", "connected to aarch64") except (gdb.error, AttributeError): --=20 2.20.1 From nobody Thu May 16 23:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1586895516; cv=none; d=zohomail.com; s=zohoarc; b=nAqIdoE43aLEXM91MjEclxB+kpw+q5PjbNcGSIwPdtueKtQ2O/rfC65T4KACdm3OYwaCAE6NKdGzCO9HuOK4WQv/6/3VrxWcQNQM6rK0A0AJm3ZXm29z/ywTs+rz2GoTdyKQ5+AODGvQs8RmgD/hISKkFKQL+4Q+15c4Lwi8ah8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586895516; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pXOAgjF0MzY5dkIyjyLAmatYK5vlyk1VB17UWTeSYLg=; b=ishVvIgTYlmTlNdxtvB+amKvA9nbBK+VyeYwzZDjuL/s7s4gkFaHJHcDaZR0lymFOqKoIIsQrAJlj1toS7SapJCesP2RQxFVxpMAOMYVAvXeu38s3BVviNiPkjCXiurB+bRpWdhf4R0OEGX+hs0I3NCGJ42EM9LaiwRxHaLDIw0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586895516759734.0673802673947; Tue, 14 Apr 2020 13:18:36 -0700 (PDT) Received: from localhost ([::1]:38624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOS0x-0006cG-8Q for importer@patchew.org; Tue, 14 Apr 2020 16:18:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45892) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jORyh-0003yT-Nc for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jORyg-0001hs-GI for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:15 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:47053) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jORyg-0001h9-A7 for qemu-devel@nongnu.org; Tue, 14 Apr 2020 16:16:14 -0400 Received: by mail-wr1-x441.google.com with SMTP id f13so16028450wrm.13 for ; Tue, 14 Apr 2020 13:16:14 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id p6sm12977676wrt.3.2020.04.14.13.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 13:16:11 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 587BD1FF9F; Tue, 14 Apr 2020 21:06:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pXOAgjF0MzY5dkIyjyLAmatYK5vlyk1VB17UWTeSYLg=; b=l3SJYTvEgPDRkSatLR4hF7MJ5Msw6QnVdjtiVi20VWWZ/2NEtk2cZuDWDkP0maoeQi /htFWipTBa7ExaFfx+BSNLxZmAawvkiskTaJE8mF9aYyi6eM3jWe23IHnpbTxXH/5K30 2x1qntg5N8Ho0VyWYIrKSas+gqg1L+dQ0nQjDNfzh1Pa5EmnQvAl/GpW4luueidC5X9M LfUv19Yjd0oX8OAlN2isV+h2Ea38wjMTL29JjxnMuwk6xkdlPQHbsN66azMtqlHbjYTN Zf8rXDm9NdUdaCiEipH/2O+tzKIjHJxkch8jCgzfHeTSvLt/fPwZd76BmP94BT8a/kB+ K6jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pXOAgjF0MzY5dkIyjyLAmatYK5vlyk1VB17UWTeSYLg=; b=azXnwoB2lT4uFWzWefGKJbCLggypFpgb6zd20POvMKPFx47cmeOAmiUSoUR0canvDP wiIKd6QFgMgJSkXOWtGalft1yc02U2KER+1S+AUdffnjqIu11pxgDVcEpP9jOpgeFwhW Vixa4ZA0JPQbcjpcX/jW8pFIcPxbWbYlnTiR47pcoso4DlSamm7DVKYQ9tmwhBOA4M3d RxoJkq/cSA3c4NtGobQDb/A7AH+jEPPig14koYGRzKQTHI+f8qU6XzHMyQI8IhcLRPEb DcgWEQ6u3fyDHVO26bIIqdWTznaElvd25ttmFcT5OakiTbpparO5tR8my0Jx9iZ7aFwA X5Kw== X-Gm-Message-State: AGi0PubcaBjsJTG9ReCs9gQppZS0ubbIE0DOf2lwel2m2PAhF1vDp9yu 2UMKCy/cYEZdUWwzczypgfAF/Bo8D5U= X-Google-Smtp-Source: APiQypLaSu3pKs0nGVbFd13L3R+mqpY2ZGE/dCFEyFZZUsPJG2wAINYZvaofW/JDSphOpNDeQDu6Hg== X-Received: by 2002:adf:fe45:: with SMTP id m5mr17771336wrs.124.1586895373108; Tue, 14 Apr 2020 13:16:13 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 17/17] tests/tcg: add a multiarch linux-user gdb test Date: Tue, 14 Apr 2020 21:06:31 +0100 Message-Id: <20200414200631.12799-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414200631.12799-1-alex.bennee@linaro.org> References: <20200414200631.12799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) When the gdbstub code was converted to the new API we missed a few snafus in the various guests. Add a simple gdb test script which can be used on all our linux-user guests to check for obvious failures. Signed-off-by: Alex Benn=C3=A9e --- tests/tcg/multiarch/Makefile.target | 15 ++++++ tests/tcg/multiarch/gdbstub/sha1.py | 81 +++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 tests/tcg/multiarch/gdbstub/sha1.py diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index 035b09c8533..47fd675aba5 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -42,5 +42,20 @@ run-test-mmap-%: test-mmap $(call run-test, test-mmap-$*, $(QEMU) -p $* $<,\ "$< ($* byte pages) on $(TARGET_NAME)") =20 +ifneq ($(HAVE_GDB_BIN),) +GDB_SCRIPT=3D$(SRC_PATH)/tests/guest-debug/run-test.py + +MULTIARCH_TESTS +=3D gdbstub-sha1 + +.PHONY: gdbstub-sha1 +run-gdbstub-sha1: sha1 + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \ + "basic gdbstub support") +endif + + # Update TESTS TESTS +=3D $(MULTIARCH_TESTS) diff --git a/tests/tcg/multiarch/gdbstub/sha1.py b/tests/tcg/multiarch/gdbs= tub/sha1.py new file mode 100644 index 00000000000..734553b98bb --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/sha1.py @@ -0,0 +1,81 @@ +from __future__ import print_function +# +# A very simple smoke test for debugging the SHA1 userspace test on +# each target. +# +# This is launched via tests/guest-debug/run-test.py +# + +import gdb +import sys + +initial_vlen =3D 0 +failcount =3D 0 + +def report(cond, msg): + "Report success/fail of test" + if cond: + print("PASS: %s" % (msg)) + else: + print("FAIL: %s" % (msg)) + global failcount + failcount +=3D 1 + +def check_break(sym_name): + "Setup breakpoint, continue and check we stopped." + sym, ok =3D gdb.lookup_symbol(sym_name) + bp =3D gdb.Breakpoint(sym_name) + + gdb.execute("c") + + # hopefully we came back + end_pc =3D gdb.parse_and_eval('$pc') + report(bp.hit_count =3D=3D 1, + "break @ %s (%s %d hits)" % (end_pc, sym.value(), bp.hit_count)) + + bp.delete() + +def run_test(): + "Run through the tests one by one" + + check_break("SHA1Init") + + # check step and inspect values + gdb.execute("next") + val_ctx =3D gdb.parse_and_eval("context->state[0]") + exp_ctx =3D 0x67452301 + report(int(val_ctx) =3D=3D exp_ctx, "context->state[0] =3D=3D %x" % ex= p_ctx); + + gdb.execute("next") + val_ctx =3D gdb.parse_and_eval("context->state[1]") + exp_ctx =3D 0xEFCDAB89 + report(int(val_ctx) =3D=3D exp_ctx, "context->state[1] =3D=3D %x" % ex= p_ctx); + + # finally check we don't barf inspecting registers + gdb.execute("info registers") + +# +# This runs as the script it sourced (via -x, via run-test.py) +# +try: + inferior =3D gdb.selected_inferior() + arch =3D inferior.architecture() + print("ATTACHED: %s" % arch.name()) +except (gdb.error, AttributeError): + print("SKIPPING (not connected)", file=3Dsys.stderr) + exit(0) + +try: + # These are not very useful in scripts + gdb.execute("set pagination off") + gdb.execute("set confirm off") + + # Run the actual tests + run_test() +except (gdb.error): + print ("GDB Exception: %s" % (sys.exc_info()[0])) + failcount +=3D 1 + pass + +print("All tests complete: %d failures" % failcount) +exit(failcount) --=20 2.20.1