From patchwork Tue Aug 29 17:02:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1827363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=AMPFPl5a; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RZtzX73xXz1yZs for ; Wed, 30 Aug 2023 03:03:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb27J-0002Zb-8S; Tue, 29 Aug 2023 13:03:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qb278-0002Sx-2l for qemu-devel@nongnu.org; Tue, 29 Aug 2023 13:02:52 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qb272-00051N-I1 for qemu-devel@nongnu.org; Tue, 29 Aug 2023 13:02:46 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1bdb7b0c8afso28366965ad.3 for ; Tue, 29 Aug 2023 10:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693328562; x=1693933362; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LGuoxVvMU6aem7Q6XdFNRJrRZCWqnrvT0uINgJVeIFY=; b=AMPFPl5aZoJvEyneJbMUO5oOVau75/4U7nXf+Z/UTSTYLn8WOBXz0/VsmI3YgpO7Hl pc5OEO5uyFbbruIJS9kQqCbVaMG5dSDMywG0W8SwhPezivuO1TLH2LWpFEs+2kigs3XG ABNxwLSm3omtqiISEUCzh3BGzz+uwH+MGqtNungd0YXNA2ebc3U5UzRrfTtGpWReif0h fEkS8ZGa3QawjS3VrvtDSxveqsDUDN5jhy4+kaFxUcUcHxrRlZ7MlSPUVISAVMK7X2WV qOnZW5ReHaISNs1cZOHlM3dHvWhs7f7Nm7pToubd1J0I1lutZvfNa/O124CJ9N7bsx/L ZClw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693328562; x=1693933362; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LGuoxVvMU6aem7Q6XdFNRJrRZCWqnrvT0uINgJVeIFY=; b=dNve8gWv4I1MCdq47xu3MadWjerKMUCvQ8uURIL4lsYvBUaOGFIgS9Yr1mnZBW4jaF S23zpzPoeVldIi6oDVrnnaFD1pWRxvP5aUDVhZcC9cBdiRJtdHgU1r37gRUvDG3AbyFg aP3bYxoee4Mw4qGVXAAqoVA6G9z3KC8Hk62R+W0gfzt24oWQG+jDdT9wJm+PRlIwLRlS XQ20k2M+7Bz1ndL//Prw4QwXl7iSlEiRokQP16s+Sd4LMb6UtoYSA5k/2iK3+XGV8h+b kvefIAgL4gXNfQKuMn4YRqsbfIMHFHOnna0VZFLO2IeyN78g1eU3+nKHVA9ahJZUutDp Cjgg== X-Gm-Message-State: AOJu0YycSKHVq6mpbXsDgtL4Y2p94QblPFMgnJJYqaY1pN+ceIDSMkgH 9MvVdZyUHi7KLAjnoxehjOdJkDvbRsuxZNDGL1k= X-Google-Smtp-Source: AGHT+IFmJ5/siakb8z5t5YE+5c4tLI0ld1TH7dZziXNC56MKDMMxmuodqQgSKUjadzMTlhnPDatKlg== X-Received: by 2002:a17:90a:cb02:b0:25e:d727:6fb4 with SMTP id z2-20020a17090acb0200b0025ed7276fb4mr23520014pjt.2.1693328562484; Tue, 29 Aug 2023 10:02:42 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id cv2-20020a17090afd0200b00267b7c5d232sm10989645pjb.48.2023.08.29.10.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 10:02:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 1/4] softmmu: Assert data in bounds in iotlb_to_section Date: Tue, 29 Aug 2023 10:02:37 -0700 Message-Id: <20230829170240.765996-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829170240.765996-1-richard.henderson@linaro.org> References: <20230829170240.765996-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Acked-by: Alex Bennée Suggested-by: Alex Bennée Signed-off-by: Richard Henderson --- softmmu/physmem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 3df73542e1..7597dc1c39 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -2413,9 +2413,15 @@ MemoryRegionSection *iotlb_to_section(CPUState *cpu, int asidx = cpu_asidx_from_attrs(cpu, attrs); CPUAddressSpace *cpuas = &cpu->cpu_ases[asidx]; AddressSpaceDispatch *d = qatomic_rcu_read(&cpuas->memory_dispatch); - MemoryRegionSection *sections = d->map.sections; + int section_index = index & ~TARGET_PAGE_MASK; + MemoryRegionSection *ret; - return §ions[index & ~TARGET_PAGE_MASK]; + assert(section_index < d->map.sections_nb); + ret = d->map.sections + section_index; + assert(ret->mr); + assert(ret->mr->ops); + + return ret; } static void io_mem_init(void) From patchwork Tue Aug 29 17:02:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1827362 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=mLdLTWTV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RZtzW0JYQz1yZs for ; Wed, 30 Aug 2023 03:03:19 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb27J-0002Zi-7a; Tue, 29 Aug 2023 13:03:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qb278-0002Sy-3R for qemu-devel@nongnu.org; Tue, 29 Aug 2023 13:02:52 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qb273-00051l-0z for qemu-devel@nongnu.org; Tue, 29 Aug 2023 13:02:47 -0400 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-26d4e1ba2dbso2638070a91.1 for ; Tue, 29 Aug 2023 10:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693328563; x=1693933363; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fWjdOHprwcmj6rv2NjOsjHYB5i71/EZpwY5eum6Xvx8=; b=mLdLTWTVRb38qFnbXFDhp8W+DiVhbxemX2L+zdUU8UfWmTpola/h7DZ4VnJ4aNj/e3 pyCwlAwndHOQCAC07JVnJS10OZBg71z/WPiugkvCuwtNWcdVKi14y/kGs0o9Fx1/WUIm SueFsaeyS9ZLLqBN5kouqZBvypVDDE7VUxHhF9BSdIZMGZQnsQJIFZOZLVfVhRMNlu4D RO+/vU0JtfxFRnTezD9zliXmDWIAUMhscFja4nBj00jRbmf/NUB1JwVi9IyH1Y2O071h iXtPpAFcT2BZm7ZJ1SK/35hUBNXqXnqp0cvO2Vit2d+fTnXvyiDRHA/jcPe5lgMvOiSl r0yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693328563; x=1693933363; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fWjdOHprwcmj6rv2NjOsjHYB5i71/EZpwY5eum6Xvx8=; b=DFpSrjF8lv2AZQdiR+FIpOs7Okvwi67QmnaKBohmJi98w2krmfaxQk9IDe0QGVuIxB TJurt6oJVIWOebD9ChB0cReqrfu/LNfslswogApkmlJilfZ0jcS4yHf3BtEgYCieHLI9 5Dgn+mTL9dvJcwHOfyke9OjBuRTDFyQ8Jetyq6R0WosMqPrsFUTaqmCBzX82eNfC9Hpl ZS3TX8x4r34Qjr+82D8EzQDFqFY8GLv/sSJRbOTxThJACOaCF5x3TcAli1+rlYiIrWAO Z5XsIm3J/WA+Kjln36wasGX4JmZ4dcOs5LRm/bCr4EajO7sGlB/vvlmdffzBtXmbSHPy ILjQ== X-Gm-Message-State: AOJu0YySD5jg0EVUrd/rhqLQc6NL7Ond94OM4EzeZsCLq2tG/ecWCFh4 QwsWh0LgtPYPm3PqVd2dSsmzp3w4iYSS3K/C6DE= X-Google-Smtp-Source: AGHT+IHVaFkZBFYRMIrmm0RuGFZisDG4R8kTdE9Z4VFqz6SRGUiZIIzeqHZnW3qlEnb1i/Y5X40E3w== X-Received: by 2002:a17:90b:3753:b0:268:c5c7:f7f1 with SMTP id ne19-20020a17090b375300b00268c5c7f7f1mr21687533pjb.29.1693328563332; Tue, 29 Aug 2023 10:02:43 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id cv2-20020a17090afd0200b00267b7c5d232sm10989645pjb.48.2023.08.29.10.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 10:02:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 2/4] softmmu: Use async_run_on_cpu in tcg_commit Date: Tue, 29 Aug 2023 10:02:38 -0700 Message-Id: <20230829170240.765996-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829170240.765996-1-richard.henderson@linaro.org> References: <20230829170240.765996-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org After system startup, run the update to memory_dispatch and the tlb_flush on the cpu. This eliminates a race, wherein a running cpu sees the memory_dispatch change but has not yet seen the tlb_flush. Since the update now happens on the cpu, we need not use qatomic_rcu_read to protect the read of memory_dispatch. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1826 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1834 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1846 Tested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/exec/cpu-common.h | 1 - accel/tcg/cpu-exec-common.c | 30 ---------------------------- softmmu/physmem.c | 40 +++++++++++++++++++++++++++---------- 3 files changed, 29 insertions(+), 42 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 87dc9a752c..41788c0bdd 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -133,7 +133,6 @@ static inline void cpu_physical_memory_write(hwaddr addr, { cpu_physical_memory_rw(addr, (void *)buf, len, true); } -void cpu_reloading_memory_map(void); void *cpu_physical_memory_map(hwaddr addr, hwaddr *plen, bool is_write); diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c index 9a5fabf625..7e35d7f4b5 100644 --- a/accel/tcg/cpu-exec-common.c +++ b/accel/tcg/cpu-exec-common.c @@ -33,36 +33,6 @@ void cpu_loop_exit_noexc(CPUState *cpu) cpu_loop_exit(cpu); } -#if defined(CONFIG_SOFTMMU) -void cpu_reloading_memory_map(void) -{ - if (qemu_in_vcpu_thread() && current_cpu->running) { - /* The guest can in theory prolong the RCU critical section as long - * as it feels like. The major problem with this is that because it - * can do multiple reconfigurations of the memory map within the - * critical section, we could potentially accumulate an unbounded - * collection of memory data structures awaiting reclamation. - * - * Because the only thing we're currently protecting with RCU is the - * memory data structures, it's sufficient to break the critical section - * in this callback, which we know will get called every time the - * memory map is rearranged. - * - * (If we add anything else in the system that uses RCU to protect - * its data structures, we will need to implement some other mechanism - * to force TCG CPUs to exit the critical section, at which point this - * part of this callback might become unnecessary.) - * - * This pair matches cpu_exec's rcu_read_lock()/rcu_read_unlock(), which - * only protects cpu->as->dispatch. Since we know our caller is about - * to reload it, it's safe to split the critical section. - */ - rcu_read_unlock(); - rcu_read_lock(); - } -} -#endif - void cpu_loop_exit(CPUState *cpu) { /* Undo the setting in cpu_tb_exec. */ diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 7597dc1c39..18277ddd67 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -680,8 +680,7 @@ address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr orig_addr, IOMMUTLBEntry iotlb; int iommu_idx; hwaddr addr = orig_addr; - AddressSpaceDispatch *d = - qatomic_rcu_read(&cpu->cpu_ases[asidx].memory_dispatch); + AddressSpaceDispatch *d = cpu->cpu_ases[asidx].memory_dispatch; for (;;) { section = address_space_translate_internal(d, addr, &addr, plen, false); @@ -2412,7 +2411,7 @@ MemoryRegionSection *iotlb_to_section(CPUState *cpu, { int asidx = cpu_asidx_from_attrs(cpu, attrs); CPUAddressSpace *cpuas = &cpu->cpu_ases[asidx]; - AddressSpaceDispatch *d = qatomic_rcu_read(&cpuas->memory_dispatch); + AddressSpaceDispatch *d = cpuas->memory_dispatch; int section_index = index & ~TARGET_PAGE_MASK; MemoryRegionSection *ret; @@ -2487,23 +2486,42 @@ static void tcg_log_global_after_sync(MemoryListener *listener) } } +static void tcg_commit_cpu(CPUState *cpu, run_on_cpu_data data) +{ + CPUAddressSpace *cpuas = data.host_ptr; + + cpuas->memory_dispatch = address_space_to_dispatch(cpuas->as); + tlb_flush(cpu); +} + static void tcg_commit(MemoryListener *listener) { CPUAddressSpace *cpuas; - AddressSpaceDispatch *d; + CPUState *cpu; assert(tcg_enabled()); /* since each CPU stores ram addresses in its TLB cache, we must reset the modified entries */ cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener); - cpu_reloading_memory_map(); - /* The CPU and TLB are protected by the iothread lock. - * We reload the dispatch pointer now because cpu_reloading_memory_map() - * may have split the RCU critical section. + cpu = cpuas->cpu; + + /* + * Defer changes to as->memory_dispatch until the cpu is quiescent. + * Otherwise we race between (1) other cpu threads and (2) ongoing + * i/o for the current cpu thread, with data cached by mmu_lookup(). + * + * In addition, queueing the work function will kick the cpu back to + * the main loop, which will end the RCU critical section and reclaim + * the memory data structures. + * + * That said, the listener is also called during realize, before + * all of the tcg machinery for run-on is initialized: thus halt_cond. */ - d = address_space_to_dispatch(cpuas->as); - qatomic_rcu_set(&cpuas->memory_dispatch, d); - tlb_flush(cpuas->cpu); + if (cpu->halt_cond) { + async_run_on_cpu(cpu, tcg_commit_cpu, RUN_ON_CPU_HOST_PTR(cpuas)); + } else { + tcg_commit_cpu(cpu, RUN_ON_CPU_HOST_PTR(cpuas)); + } } static void memory_map_init(void) From patchwork Tue Aug 29 17:02:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1827364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=D0jHLErS; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RZtzx6d8Jz1yZs for ; Wed, 30 Aug 2023 03:03:40 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb27K-0002dS-Us; Tue, 29 Aug 2023 13:03:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qb278-0002T0-4G for qemu-devel@nongnu.org; Tue, 29 Aug 2023 13:02:52 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qb273-00051r-KT for qemu-devel@nongnu.org; Tue, 29 Aug 2023 13:02:48 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68a440a8a20so3985164b3a.3 for ; Tue, 29 Aug 2023 10:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693328564; x=1693933364; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ubwo0TEFtdkb/m6/OLcsmvm92SJ7iM0Jve66C5kvkAs=; b=D0jHLErSUKSOK/5+14eaeR1Ng8Tsp9HFtEd5jLGv8XGh+lhlUxZUpMTSR111pHOWgs +GfoUURNCGLE6yAm67WvXe7mHQdWg4PscdYwGcoe6r7x7ukM1ZPY+6Z/PUzZGrprwb8r wPS1Rhmn596CKb0jJck+rXONcOXHhgkkfhLKj6D5yI5RL196azPCYKkuZwM7iRI3NPb1 JX+yXB8KehqHIh4xZmFhoGkeQjhh1WkgdnygsFfjvPlrENZc5WrCShOWjX3U6x/GciyP 0jtsr8bTdAjpDrEXB5IrJyN5l95Xwypv5OZHsf6O4sQRRKuBuv9UA20gNGzGpnl4NJ3W aHzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693328564; x=1693933364; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ubwo0TEFtdkb/m6/OLcsmvm92SJ7iM0Jve66C5kvkAs=; b=N+lCysa3DnSmUMeM5DNP5Z1OUv7YgiKgLrwxnc7PsCho+rmWNHP3K80KDscu7g0rF8 NIMZO2YNTRvrwyuF/5Vps1bgNaCxRSLyBXVmC+2JNR3Kt5iJr4EbWkbreY17FQf5iuFk qBmNJDC1ehohnwTcDU/iXMA5I7v4iKtv+zpZHmUdBYr+ch9sHdTRfGO3fR+ie2wLTnve z1LKhJ3nJ7VyGsXAL+bvUow0swEUgNKGp1mkrDnWHNdF8qYgzSZiNkEXPDlUiphJY6nN 1pYExDP6AZU3lIvxfPoHAKZHlZ5+2zQcFqLcgWbZDKsjmG+BoHljjGRds1HvmrkakKmV 0B4g== X-Gm-Message-State: AOJu0Yz7ZmfPbMTeFfRv0CzZOo8cydwd3TFIP7xjRlWjb22VxoyZ7PeA h2ThwGj1v2i30cA093O3nZRyC1mMGBE5yfA/bqk= X-Google-Smtp-Source: AGHT+IHVnarea3StNV2FOBOxgqAjB+UbfnrPUaVUSZQRqWGBzbTDObU9bXGsX3EyWWERIZBMpfPt0w== X-Received: by 2002:a17:90a:9ac:b0:268:60d9:92cc with SMTP id 41-20020a17090a09ac00b0026860d992ccmr27344337pjo.43.1693328564183; Tue, 29 Aug 2023 10:02:44 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id cv2-20020a17090afd0200b00267b7c5d232sm10989645pjb.48.2023.08.29.10.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 10:02:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 3/4] tcg: Remove vecop_list check from tcg_gen_not_vec Date: Tue, 29 Aug 2023 10:02:39 -0700 Message-Id: <20230829170240.765996-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829170240.765996-1-richard.henderson@linaro.org> References: <20230829170240.765996-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The not pattern is always available via generic expansion. See debug block in tcg_can_emit_vecop_list. Fixes: 11978f6f58 ("tcg: Fix expansion of INDEX_op_not_vec") Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg-op-vec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index ad8ee08a7e..094298bb27 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -391,12 +391,11 @@ static bool do_op2(unsigned vece, TCGv_vec r, TCGv_vec a, TCGOpcode opc) void tcg_gen_not_vec(unsigned vece, TCGv_vec r, TCGv_vec a) { - const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL); - - if (!TCG_TARGET_HAS_not_vec || !do_op2(vece, r, a, INDEX_op_not_vec)) { + if (TCG_TARGET_HAS_not_vec) { + vec_gen_op2(INDEX_op_not_vec, 0, r, a); + } else { tcg_gen_xor_vec(0, r, a, tcg_constant_vec_matching(r, 0, -1)); } - tcg_swap_vecop_list(hold_list); } void tcg_gen_neg_vec(unsigned vece, TCGv_vec r, TCGv_vec a) From patchwork Tue Aug 29 17:02:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1827365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Xo5IKTWH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RZv062sdWz1yZs for ; Wed, 30 Aug 2023 03:03:50 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb27L-0002dw-4X; Tue, 29 Aug 2023 13:03:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qb27B-0002Th-4C for qemu-devel@nongnu.org; Tue, 29 Aug 2023 13:02:53 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qb276-000525-N8 for qemu-devel@nongnu.org; Tue, 29 Aug 2023 13:02:51 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c0d5b16aacso27116625ad.1 for ; Tue, 29 Aug 2023 10:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693328565; x=1693933365; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=aHirIWaDFAatgvDo4fYP79xIs5dz8DP+SlTM+t8FRU4=; b=Xo5IKTWHbHm9Zjk6fGreRtx4nQnxS98zt/IIIRsYXhzS447PbsjGMa3JaRe1WSNiOu +KBxqwvPvbn292Gi2DDmcZG9dIqUVUbEyz9QWeZ4qpszS9b5YJ9Koq5DnbkbxplPPMsb F+NytoHLrLv5QA1QmAkDQmIfGtDJPhaPepDJlPY0EeIuJxF5dO//9OVl+zUlmA2cWBnf MjJGIbthVrf5tn35M894ojMPSLuEPiZOf7IyfJq6LPbCtZA06LBiUekyjdSvXykVF4on jZDmcFE1ra4ddeO3Anm0oDtwjBz+JpjWN1DR7dtoUGic2ijlgHAbRb2DoejDF/Ve71xr gEpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693328565; x=1693933365; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aHirIWaDFAatgvDo4fYP79xIs5dz8DP+SlTM+t8FRU4=; b=Tm3HSKGHut9Au5NEcGOBLvuJ1BKOBvdnC2plqhNEF0X6fd8uRrIIlwhYHzSKTO2vIx kIXRD204g7ztRTwP4A0dUq/1CR5MlwgDNvfZ3mPC7wIdY+09akMZq8vNM/0UfSMhtpQ5 CDRKXDdX/oLr8qEYXViXBECGKMBbza0gma4aOzwrLo/PFcxuCHUg7L+hWl9wfS1B+dbI kf8KHCDlbVsInY3gSqQJ750p+2q80JuztKXwNy12ndV5qX1bf+dkz0vlOzSHnhwzexOY PDeYSSCoUjwr4tAY7MfjeUji/33We1MiXvrAgNgehF3X85BbrraiDj77l+jKmNUAuQ+C pSgw== X-Gm-Message-State: AOJu0Yze7W9vZogkM5I2FX3szIWpjm/wyujC9HbVX0Qr/TQ/IXZ6NOIa Aqdzb5rbz8JBTa3BsH0h7OeEM76RMYBTPl/ag8k= X-Google-Smtp-Source: AGHT+IHvDK7Tw2OZ+eK0uv6DDqioTME8yAzizJJwcJw+wqK8c2o+vFalFlw6+Z4MQdb1OhGgdTeWag== X-Received: by 2002:a17:90a:ca16:b0:263:fc45:4091 with SMTP id x22-20020a17090aca1600b00263fc454091mr22281687pjt.15.1693328564937; Tue, 29 Aug 2023 10:02:44 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id cv2-20020a17090afd0200b00267b7c5d232sm10989645pjb.48.2023.08.29.10.02.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 10:02:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 4/4] tcg/sparc64: Disable TCG_TARGET_HAS_extr_i64_i32 Date: Tue, 29 Aug 2023 10:02:40 -0700 Message-Id: <20230829170240.765996-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829170240.765996-1-richard.henderson@linaro.org> References: <20230829170240.765996-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Since a59a29312660 ("tcg/sparc64: Remove sparc32plus constraints") we no longer distinguish registers with 32 vs 64 bits. Therefore we can remove support for the backend-specific type change opcodes. Signed-off-by: Richard Henderson --- tcg/sparc64/tcg-target.h | 2 +- tcg/sparc64/tcg-target.c.inc | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h index 3d41c9659b..5cfc4b4679 100644 --- a/tcg/sparc64/tcg-target.h +++ b/tcg/sparc64/tcg-target.h @@ -115,7 +115,7 @@ extern bool use_vis3_instructions; #define TCG_TARGET_HAS_mulsh_i32 0 #define TCG_TARGET_HAS_qemu_st8_i32 0 -#define TCG_TARGET_HAS_extr_i64_i32 1 +#define TCG_TARGET_HAS_extr_i64_i32 0 #define TCG_TARGET_HAS_div_i64 1 #define TCG_TARGET_HAS_rem_i64 0 #define TCG_TARGET_HAS_rot_i64 0 diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index f2a346a1bd..81a08bb6c5 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -529,11 +529,6 @@ static void tcg_out_extu_i32_i64(TCGContext *s, TCGReg rd, TCGReg rs) tcg_out_ext32u(s, rd, rs); } -static void tcg_out_extrl_i64_i32(TCGContext *s, TCGReg rd, TCGReg rs) -{ - tcg_out_mov(s, TCG_TYPE_I32, rd, rs); -} - static bool tcg_out_xchg(TCGContext *s, TCGType type, TCGReg r1, TCGReg r2) { return false; @@ -1444,9 +1439,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_divu_i64: c = ARITH_UDIVX; goto gen_arith; - case INDEX_op_extrh_i64_i32: - tcg_out_arithi(s, a0, a1, 32, SHIFT_SRLX); - break; case INDEX_op_brcond_i64: tcg_out_brcond_i64(s, a2, a0, a1, const_args[1], arg_label(args[3])); @@ -1501,7 +1493,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_ext32u_i64: case INDEX_op_ext_i32_i64: case INDEX_op_extu_i32_i64: - case INDEX_op_extrl_i64_i32: default: g_assert_not_reached(); } @@ -1533,8 +1524,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_ext32u_i64: case INDEX_op_ext_i32_i64: case INDEX_op_extu_i32_i64: - case INDEX_op_extrl_i64_i32: - case INDEX_op_extrh_i64_i32: case INDEX_op_qemu_ld_a32_i32: case INDEX_op_qemu_ld_a64_i32: case INDEX_op_qemu_ld_a32_i64: