From patchwork Tue Nov 14 19:26:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 743797 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp2364276wrw; Tue, 14 Nov 2023 11:27:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPeZdFx+RB3FnE5LkwBMsnMjYm8Cr7GSLagrMQClljIQok5S75KKRVe4HD2MGS5H3ocTkM X-Received: by 2002:ac8:5d41:0:b0:419:4d8a:336 with SMTP id g1-20020ac85d41000000b004194d8a0336mr4027804qtx.60.1699990074099; Tue, 14 Nov 2023 11:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699990074; cv=none; d=google.com; s=arc-20160816; b=FPwUxi0ElgLthJGza+4DVVcw1X0rUqkkGZn+Zcfz6B6I1jh0ckSYkvxmckR1+Er6Gv SQkVlvJFBPDgqMZtrnxCCVXWR7wPdrnSnuCfzygGBzY0j9UnSp3nWi1Z+3SDlcY+tUSg 8QJaW9iyidq1b9nwdjFw0nVKWahyn5pG3QfqPXtbxaiiF4Mr+uvKAUQ0Z6phj0JbNHEX tVD85arO5F5I1CRk4W2svQZtLFct+UnR+cRX4oOdi51XPODrHe7RyzOlu7oK4Ns2/GuD TKzzmlMBj/EH4CrkV3fxkdp8OeapPLUan4pm03TwZ9LGL6HWqejshd9DvBa6M/CJB4RE n+9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U5juuJ7X5jTEcQbetRFuXGDhp1OBOcXOBoH2eS6RKpA=; fh=O6pUHsYGRUUkDZW036p0MshHYtZZ3rhv3UH2O6JOjRc=; b=RC/cUbJekDERLAxX85FA4bGRqK+WCXmgx2gs6sE8WOldimdvxhs9MfU3evpjGHo6QA jYzBqkkwCaDtEAgrGXc9EoNKyVhaTJsHUerddlSNtDRrl1hot7sJSUqtPmo/MPXksxP+ oz2yBTD8kz8IMoGJRuJ0h2fSkIKjlECadkbj4T9+AeoLT6l4PzuPDbStuVN40q7lQ7KT xfCeNsPoiDI1gxmUtnNcqD993txYkQ4tEjNqHsKBN+U//nJRM4wxR6BNm88o3xTLKTrm BJv390ZBvgHWuAOjVf8frU4YWHXY7go0/anE0luka70Khfl3Iihq141w3HMs/ofCOWSH VlOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bJPyVhU1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m14-20020a05622a054e00b0041971a2b466si6963483qtx.715.2023.11.14.11.27.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Nov 2023 11:27:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bJPyVhU1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2z3w-0003tc-3a; Tue, 14 Nov 2023 14:27:04 -0500 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 1r2z3u-0003sd-HP for qemu-devel@nongnu.org; Tue, 14 Nov 2023 14:27:02 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2z3s-00070P-Ar for qemu-devel@nongnu.org; Tue, 14 Nov 2023 14:27:02 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1cc37fb1310so45926445ad.1 for ; Tue, 14 Nov 2023 11:26:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699990019; x=1700594819; darn=nongnu.org; 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=U5juuJ7X5jTEcQbetRFuXGDhp1OBOcXOBoH2eS6RKpA=; b=bJPyVhU1UVRPhn7xoJ/rgmANYsRkVwa1eUYF3by/JmcgLSNIbezEcoVqvaHv9Oj05F HNR6G/fS/HCMIUZAy9kCxptPQw0pyg+TLUwG3lQH/X9LPAxagN4zz41gktf94s5Q96aR vpPrl4o7uhBcuIZ6cAHmBGNlRAPT2m3yF5QAKuE7PjRHeeVhyd0VK/O86js/8f88kO6O z3+JAgbMSsSPJAOVGaV5zXRqyc9hXjVhJUree5suq3i0BdMJBa8XxYCcWj0jX+prMgvt 8cE4ho+5e17RCjYQKFIb5Bnfumjq0PxepjJQFGrGgyNfFVxdgxXbG2ptbYUdRRqFPviL q5qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699990019; x=1700594819; 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=U5juuJ7X5jTEcQbetRFuXGDhp1OBOcXOBoH2eS6RKpA=; b=F9fgM9AYat/CtP5C4EwQbBeEq2OTllcODh6mNPsCfk4IV3oyRdK5MyHGiIv2ocAVs4 fBNQku1x0gXz/5PUrfWfGbMtcAZ4cbSWYICWiiVbEzSQEnZf6vt+gUsc4V9F0fXUVURS dTNyKdMz1BQtFcUg7vUPJ8hhSThXfKy3cd6FGfw7b8cF5qrrbewAN6DepRAp7/3XYqNJ toriJmkKC4sqqYENh4WE/zRaAqCoonpgswX3VpQcyHEoC83CxUvDynUlgz66/xmKhP3b 3fxjLGJSQLxEPnELR8C70EbVhnebiIrihCHBBob1qlNaXByPLFNjN8jC0n0IVp9DvM46 p6Jw== X-Gm-Message-State: AOJu0YyAz4zdGnoCGnr0FhDyVnhRz7umHsaiimqqUUBr4I76GPLlPEU6 4Aly34mZuw+e8OJZrPW97POMsnGU2vYXMZTxhKA= X-Received: by 2002:a17:902:b608:b0:1cc:4985:fbf8 with SMTP id b8-20020a170902b60800b001cc4985fbf8mr2814683pls.59.1699990018821; Tue, 14 Nov 2023 11:26:58 -0800 (PST) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id j18-20020a170902c3d200b001c728609574sm6052643plj.6.2023.11.14.11.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 11:26:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Cl=C3=A9ment_Chigot?= , Claudio Fontana Subject: [PULL 1/3] accel/tcg: Remove CF_LAST_IO Date: Tue, 14 Nov 2023 11:26:54 -0800 Message-Id: <20231114192656.176451-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114192656.176451-1-richard.henderson@linaro.org> References: <20231114192656.176451-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In cpu_exec_step_atomic, we did not set CF_LAST_IO, which lead to a loop with cpu_io_recompile. But since 18a536f1f8 ("Always require can_do_io") we no longer need a flag to indicate when the last insn should have can_do_io set, so remove the flag entirely. Reported-by: Clément Chigot Tested-by: Clément Chigot Reviewed-by: Claudio Fontana Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1961 Signed-off-by: Richard Henderson --- docs/devel/tcg-icount.rst | 6 ------ include/exec/translation-block.h | 13 ++++++------- accel/tcg/cpu-exec.c | 2 +- accel/tcg/tb-maint.c | 6 ++---- accel/tcg/translate-all.c | 4 ++-- accel/tcg/translator.c | 22 +++++++++------------- system/watchpoint.c | 6 ++---- 7 files changed, 22 insertions(+), 37 deletions(-) diff --git a/docs/devel/tcg-icount.rst b/docs/devel/tcg-icount.rst index 50c8e8dabc..7df883446a 100644 --- a/docs/devel/tcg-icount.rst +++ b/docs/devel/tcg-icount.rst @@ -62,12 +62,6 @@ To deal with this case, when an I/O access is made we: - re-compile a single [1]_ instruction block for the current PC - exit the cpu loop and execute the re-compiled block -The new block is created with the CF_LAST_IO compile flag which -ensures the final instruction translation starts with a call to -gen_io_start() so we don't enter a perpetual loop constantly -recompiling a single instruction block. For translators using the -common translator_loop this is done automatically. - .. [1] sometimes two instructions if dealing with delay slots Other I/O operations diff --git a/include/exec/translation-block.h b/include/exec/translation-block.h index b785751774..e2b26e16da 100644 --- a/include/exec/translation-block.h +++ b/include/exec/translation-block.h @@ -71,13 +71,12 @@ struct TranslationBlock { #define CF_NO_GOTO_TB 0x00000200 /* Do not chain with goto_tb */ #define CF_NO_GOTO_PTR 0x00000400 /* Do not chain with goto_ptr */ #define CF_SINGLE_STEP 0x00000800 /* gdbstub single-step in effect */ -#define CF_LAST_IO 0x00008000 /* Last insn may be an IO access. */ -#define CF_MEMI_ONLY 0x00010000 /* Only instrument memory ops */ -#define CF_USE_ICOUNT 0x00020000 -#define CF_INVALID 0x00040000 /* TB is stale. Set with @jmp_lock held */ -#define CF_PARALLEL 0x00080000 /* Generate code for a parallel context */ -#define CF_NOIRQ 0x00100000 /* Generate an uninterruptible TB */ -#define CF_PCREL 0x00200000 /* Opcodes in TB are PC-relative */ +#define CF_MEMI_ONLY 0x00001000 /* Only instrument memory ops */ +#define CF_USE_ICOUNT 0x00002000 +#define CF_INVALID 0x00004000 /* TB is stale. Set with @jmp_lock held */ +#define CF_PARALLEL 0x00008000 /* Generate code for a parallel context */ +#define CF_NOIRQ 0x00010000 /* Generate an uninterruptible TB */ +#define CF_PCREL 0x00020000 /* Opcodes in TB are PC-relative */ #define CF_CLUSTER_MASK 0xff000000 /* Top 8 bits are cluster ID */ #define CF_CLUSTER_SHIFT 24 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 1a5bc90220..c938eb96f8 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -721,7 +721,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) && cpu->neg.icount_decr.u16.low + cpu->icount_extra == 0) { /* Execute just one insn to trigger exception pending in the log */ cpu->cflags_next_tb = (curr_cflags(cpu) & ~CF_USE_ICOUNT) - | CF_LAST_IO | CF_NOIRQ | 1; + | CF_NOIRQ | 1; } #endif return false; diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index e678d20dc2..3d2a896220 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -1083,8 +1083,7 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc) if (current_tb_modified) { /* Force execution of one insn next time. */ CPUState *cpu = current_cpu; - cpu->cflags_next_tb = - 1 | CF_LAST_IO | CF_NOIRQ | curr_cflags(current_cpu); + cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu); return true; } return false; @@ -1154,8 +1153,7 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, if (current_tb_modified) { page_collection_unlock(pages); /* Force execution of one insn next time. */ - current_cpu->cflags_next_tb = - 1 | CF_LAST_IO | CF_NOIRQ | curr_cflags(current_cpu); + current_cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu); mmap_unlock(); cpu_loop_exit_noexc(current_cpu); } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index b263857ecc..79a88f5fb7 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -304,7 +304,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, if (phys_pc == -1) { /* Generate a one-shot TB with 1 insn in it */ - cflags = (cflags & ~CF_COUNT_MASK) | CF_LAST_IO | 1; + cflags = (cflags & ~CF_COUNT_MASK) | 1; } max_insns = cflags & CF_COUNT_MASK; @@ -632,7 +632,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) * operations only (which execute after completion) so we don't * double instrument the instruction. */ - cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | CF_LAST_IO | n; + cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | n; if (qemu_loglevel_mask(CPU_LOG_EXEC)) { vaddr pc = log_pc(cpu, tb); diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 575b9812ad..38c34009a5 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -89,7 +89,7 @@ static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags) * each translation block. The cost is minimal, plus it would be * very easy to forget doing it in the translator. */ - set_can_do_io(db, db->max_insns == 1 && (cflags & CF_LAST_IO)); + set_can_do_io(db, db->max_insns == 1); return icount_start_insn; } @@ -151,13 +151,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, ops->tb_start(db, cpu); tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */ - if (cflags & CF_MEMI_ONLY) { - /* We should only see CF_MEMI_ONLY for io_recompile. */ - assert(cflags & CF_LAST_IO); - plugin_enabled = plugin_gen_tb_start(cpu, db, true); - } else { - plugin_enabled = plugin_gen_tb_start(cpu, db, false); - } + plugin_enabled = plugin_gen_tb_start(cpu, db, cflags & CF_MEMI_ONLY); db->plugin_enabled = plugin_enabled; while (true) { @@ -169,11 +163,13 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, plugin_gen_insn_start(cpu, db); } - /* Disassemble one instruction. The translate_insn hook should - update db->pc_next and db->is_jmp to indicate what should be - done next -- either exiting this loop or locate the start of - the next instruction. */ - if (db->num_insns == db->max_insns && (cflags & CF_LAST_IO)) { + /* + * Disassemble one instruction. The translate_insn hook should + * update db->pc_next and db->is_jmp to indicate what should be + * done next -- either exiting this loop or locate the start of + * the next instruction. + */ + if (db->num_insns == db->max_insns) { /* Accept I/O on the last instruction. */ set_can_do_io(db, true); } diff --git a/system/watchpoint.c b/system/watchpoint.c index 45d1f12faf..ba5ad13352 100644 --- a/system/watchpoint.c +++ b/system/watchpoint.c @@ -179,8 +179,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, */ if (!cpu->neg.can_do_io) { /* Force execution of one insn next time. */ - cpu->cflags_next_tb = 1 | CF_LAST_IO | CF_NOIRQ - | curr_cflags(cpu); + cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(cpu); cpu_loop_exit_restore(cpu, ra); } /* @@ -212,8 +211,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, cpu_loop_exit(cpu); } else { /* Force execution of one insn next time. */ - cpu->cflags_next_tb = 1 | CF_LAST_IO | CF_NOIRQ - | curr_cflags(cpu); + cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(cpu); mmap_unlock(); cpu_loop_exit_noexc(cpu); } From patchwork Tue Nov 14 19:26:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 743796 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp2364191wrw; Tue, 14 Nov 2023 11:27:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGjnYsQy5A4u8SyJ9Vd6QrBCCkRv7Pfaevv/ngTBW3BF6VZhW2NYkmOIwn4cMrTlu+0rH41 X-Received: by 2002:a05:622a:144e:b0:421:ac6d:c091 with SMTP id v14-20020a05622a144e00b00421ac6dc091mr3869794qtx.9.1699990063619; Tue, 14 Nov 2023 11:27:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699990063; cv=none; d=google.com; s=arc-20160816; b=muTpWxIJTPI6uNWjwbfoN/wAh8G3+DapI1GtnulcId3qM5U79ZdLZhmjWiBnSFfp3c +nZmyKykMti5yzpc/FWiYvwJQXSc7jNtQcFyJM2P+pp9vJ12rY9QqFVkjgY5Sf7zPEor BEaSzniG3TRdogFViIqDN+K8qxe9I1gshtNXRsc4bF4hftxRNy2pp3JLekAwHN+rDNlX Tdr1OhZkFeFycZkaMkJ/zTPy57vmix3b4WyNO+G8klGSL5of1hKIQ0rGq7z8lvfCUUAZ q/RH49Ei+0PoxLC9C5q2B4+48h6sxf9rXK4VC6iV80IVjaSs7fArdeb5zvTBjOk1+1D1 R/Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JLKWYDsjkvpifTsfNAx+wzg8HUX4emgmt/2POiSK9Os=; fh=uiQc+DS/nlY6bdrAXTaUKgIYOvPgZAm+7gW+W7psDuQ=; b=iQ5sS7krU65FDnxSGrjySptBLpkAKZr9HeoGh3t0JfY81Mt7JJHakJOJckvTBE69PE ZRF3kAKIQZXsoFSFb3zckSLXkHG++SPgTmeA95Npudy9rgeVpUjib72Y/O4kqC9GDleA ejrXusgfq+WvtnlQ14Y/VYskmhZ/vK2vgHoY9bEmeIKNokYtMt4mu9WfprgEyhCmk7MQ SkkgHRV8/I+WOhpGtK9//TEPs6MBNCu1vVGRae0faaBex7SYPQhyRFd4A+IFOWYCN4kl cUxLET3HdAKH2xnTkLEsUiyScgJcXqpcGaMLNGlh2gosBsNKQBcj5ku2RvRbVxY9BfEJ xF/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IrUj1vtl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c14-20020ac87d8e000000b0041cb522af96si7612888qtd.347.2023.11.14.11.27.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Nov 2023 11:27:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IrUj1vtl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2z3w-0003tl-OA; Tue, 14 Nov 2023 14:27:04 -0500 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 1r2z3v-0003st-5N for qemu-devel@nongnu.org; Tue, 14 Nov 2023 14:27:03 -0500 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2z3t-00070Z-4b for qemu-devel@nongnu.org; Tue, 14 Nov 2023 14:27:02 -0500 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-565334377d0so4707674a12.2 for ; Tue, 14 Nov 2023 11:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699990019; x=1700594819; darn=nongnu.org; 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=JLKWYDsjkvpifTsfNAx+wzg8HUX4emgmt/2POiSK9Os=; b=IrUj1vtl3lydx3pquErtIpRxF5qV9ufMkAsoWDpwfY9y4Z/aKDvNN3QHIGDNeQ2iIn gHr5zCzkVB1uRY8meJDJvWZMfu0THZk4PivtvC5kD2XvLW28oBoqJ1Fm+44PSdr3sR3T aUHZzh0ENKEcj1r4ze0beBH/ciK7uUBtqDJTW/ugn7UmJvh/SdQgS8kQGvvbeM5hZTCY eIFx9aGApo0poHDo/qMhc9lQ8cJBXoGEfsywh+sjA+/wsAGl39IQRFqip0ix7sBGxejX Ielt4iQJsnESeIKouWmE6OYm672zs5cmYtL5Ol+0yg63gGPcBl+Vr8sd1+LYdUN6CUhz 8Ecg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699990019; x=1700594819; 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=JLKWYDsjkvpifTsfNAx+wzg8HUX4emgmt/2POiSK9Os=; b=jmH+laqxZGUTFfx5CX8BHGdeylZzQ5nv+xkW7LCA4jyrwF7q7trTjdKbrOkSbtxYRK Okz1O73Pe63prhhB0+CXmFIdYXUVW1X/RayhCB+q8ppwuNvUi4z2+Z/usM99CwnJXCoU GhBsD8VG+HxmjkdsTUvxEw+t+jlAs6sdf5bPN590o9MLXgpYYPRid1jrw+jOlE5zc4IF MBuLc7G5lfc+iX3T1DpqQJa6T9C4LGt/LFzWzxzEYEbB89CnycIdgBqO2JLbe+zpQWCB g86v/JkNpU6g6/4h/2yWzO/gIbkZsjJ7Zvkbe7pyCEK8eSRVLynumFoEK5/aaJHtsRjB wu5Q== X-Gm-Message-State: AOJu0YwtLdcUh5nypOnK+n8EZ8u9rAJNsaxV+RfHplgs9k7L4ETaMawy e21K1rmJDrzpit+kzX4Zr4V7OLJlwqKdp8qw5SE= X-Received: by 2002:a17:902:6b88:b0:1cc:2eda:bde8 with SMTP id p8-20020a1709026b8800b001cc2edabde8mr3228989plk.24.1699990019599; Tue, 14 Nov 2023 11:26:59 -0800 (PST) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id j18-20020a170902c3d200b001c728609574sm6052643plj.6.2023.11.14.11.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 11:26:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Jessica Clarke Subject: [PULL 2/3] accel/tcg: Forward probe size on to notdirty_write Date: Tue, 14 Nov 2023 11:26:55 -0800 Message-Id: <20231114192656.176451-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114192656.176451-1-richard.henderson@linaro.org> References: <20231114192656.176451-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Jessica Clarke Without this, we just dirty a single byte, and so if the caller writes more than one byte to the host memory then we won't have invalidated any translation blocks that start after the first byte and overlap those writes. In particular, AArch64's DC ZVA implementation uses probe_access (via probe_write), and so we don't invalidate the entire block, only the TB overlapping the first byte (and, in the unusual case an unaligned VA is given to the instruction, we also probe that specific address in order to get the right VA reported on an exception, so will invalidate a TB overlapping that address too). Since our IC IVAU implementation is a no-op for system emulation that relies on the softmmu already having detected self-modifying code via this mechanism, this means we have observably wrong behaviour when jumping to code that has been DC ZVA'ed. In practice this is an unusual thing for software to do, as in reality the OS will DC ZVA the page and the application will go and write actual instructions to it that aren't UDF #0, but you can write a test that clearly shows the faulty behaviour. For functions other than probe_access it's not clear what size to use when 0 is passed in. Arguably a size of 0 shouldn't dirty at all, since if you want to actually write then you should pass in a real size, but I have conservatively kept the implementation as dirtying the first byte in that case so as to avoid breaking any assumptions about that behaviour. Signed-off-by: Jessica Clarke Message-Id: <20231104031232.3246614-1-jrtc27@jrtc27.com> [rth: Move the dirtysize computation next to notdirty_write.] Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 765805e70b..db3f93fda9 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1479,7 +1479,8 @@ int probe_access_full(CPUArchState *env, vaddr addr, int size, /* Handle clean RAM pages. */ if (unlikely(flags & TLB_NOTDIRTY)) { - notdirty_write(env_cpu(env), addr, 1, *pfull, retaddr); + int dirtysize = size == 0 ? 1 : size; + notdirty_write(env_cpu(env), addr, dirtysize, *pfull, retaddr); flags &= ~TLB_NOTDIRTY; } @@ -1502,7 +1503,8 @@ int probe_access_full_mmu(CPUArchState *env, vaddr addr, int size, /* Handle clean RAM pages. */ if (unlikely(flags & TLB_NOTDIRTY)) { - notdirty_write(env_cpu(env), addr, 1, *pfull, 0); + int dirtysize = size == 0 ? 1 : size; + notdirty_write(env_cpu(env), addr, dirtysize, *pfull, 0); flags &= ~TLB_NOTDIRTY; } @@ -1524,7 +1526,8 @@ int probe_access_flags(CPUArchState *env, vaddr addr, int size, /* Handle clean RAM pages. */ if (unlikely(flags & TLB_NOTDIRTY)) { - notdirty_write(env_cpu(env), addr, 1, full, retaddr); + int dirtysize = size == 0 ? 1 : size; + notdirty_write(env_cpu(env), addr, dirtysize, full, retaddr); flags &= ~TLB_NOTDIRTY; } @@ -1560,7 +1563,7 @@ void *probe_access(CPUArchState *env, vaddr addr, int size, /* Handle clean RAM pages. */ if (flags & TLB_NOTDIRTY) { - notdirty_write(env_cpu(env), addr, 1, full, retaddr); + notdirty_write(env_cpu(env), addr, size, full, retaddr); } } From patchwork Tue Nov 14 19:26:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 743795 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp2364118wrw; Tue, 14 Nov 2023 11:27:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzjVbCOilRxxTMqED0NBh9WbRPOV5eW2FAyGUBFWkv9jzoxjIKpqGocmmMYe20/Bx0c98L X-Received: by 2002:a05:6358:8a6:b0:168:d0d4:d8e6 with SMTP id m38-20020a05635808a600b00168d0d4d8e6mr4846920rwj.16.1699990050363; Tue, 14 Nov 2023 11:27:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699990050; cv=none; d=google.com; s=arc-20160816; b=HSKyiDoBLmLv+5KfMjqIwe1hAdk18R10rzjactkMINtggDXwj/g7NrEInZ/vvE6qTn CNbbgP4qiA12v5Ij5We1LV0BzeHRe+gzIxVQuLBIPlgmbVs51ruEaTnihN/lnGSKXsO1 jjTZ+R5RxzgBqa+EQX9gnqKC8j82YFCe0kzbp4pC7JEomPu6zoc9zbC3ysXFlSZc9GWL IQMnczqHakV3Mzn524oUpEgE5WMDOIh1YlIa5UqqxKDtQI9QmTwpfSdvaPYaYFOB09m1 /zcPueZECAielPv1qa5DE3WKgedAApgwpaCRkd3WSwjD6/8itWrFUOm3q/AMc3cDAckg 2GJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YU1go63PndchrVnK6DHWLmkVnDCLAEuAU/t//fUCSL8=; fh=J4M4Z4TZxvAT8lkmK1LtxqMjpO7Qiod4IMBL2bk0hxA=; b=wqMaJcWZ4twwXuTf3sbSDUJMyy9CzpxCsLwP8/9pGfwtiySS6W7wuYBBsOH+xBD3Nn l2YXleSINDVj+zMXRyg5LYUel8iTVn/xvYIMJFX767fPHdE5nLL8W8mTqWCaMR+BN6OT CpGpTrJJR5N0HFUsJIKCj5D8owrGBPw3YnUTlozwp06Rg519S7tu9RRq7CzEg6i5x+En Pv+HUjXcHxKkZ1jRkvG9Ud24RKTUCEb1TG4xldUFGO0EK5TIisTk0ZI8CljDyM074L47 Pz+ROjghKNfL+l6u7OKegQeLCh5/mgrBp8nVYvx+lN4USodULaJSD/Z0GsZY3+odPEsF ho2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=apjY9uTQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g13-20020ac87d0d000000b004069f6c1ec7si7554904qtb.668.2023.11.14.11.27.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Nov 2023 11:27:30 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=apjY9uTQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2z3x-0003ts-JD; Tue, 14 Nov 2023 14:27:05 -0500 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 1r2z3v-0003tW-RS for qemu-devel@nongnu.org; Tue, 14 Nov 2023 14:27:03 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2z3u-00070e-Ac for qemu-devel@nongnu.org; Tue, 14 Nov 2023 14:27:03 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1cc3542e328so45124915ad.1 for ; Tue, 14 Nov 2023 11:27:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699990020; x=1700594820; darn=nongnu.org; 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=YU1go63PndchrVnK6DHWLmkVnDCLAEuAU/t//fUCSL8=; b=apjY9uTQYnXdfj26MSngIfqL69GokTmwPbrjmLKVROSwvxol9MihKQNgrGalLVuRn8 crsTkfgh/tiZq12b0C6qmc6kyuCTpVdfV1eLtaJOUmeCNXPJ0nySum5cN6utoA+m/SGx +rf5YqHY7rcZJuv8F++XiCHDZp+rJA3DkWWBsq0vBAxY4uAlwu1ecNVRBAmINZoioA6D OixZqXZYPMVDEUvMbpHOCAZ6t/9MIaFck88Gst/D3TmxaQNa55vGcmnHa2wKTscOizV7 J4jDayVPpMWN3OQ9n4WwJzh9pJomWte0aoTRiQ6p6X1ciJCV476g+N+UWONZvFybrQLO FNNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699990020; x=1700594820; 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=YU1go63PndchrVnK6DHWLmkVnDCLAEuAU/t//fUCSL8=; b=DeSS9kjvQQIIpqWTs2+/GZQvlcB6JWZGglNk6UPdil3xNzuGeWTdRJpFEbo71is4gJ nl3z1XHQPdnakcEhoheV+lOhX+CFBxqwXxWniPOaPdhOoIVEcCTXyAupVjuGZN2PiYwH eclFjprXvjP0Pk0Vi1+eWVSo3eZUO4uxRXY940q045zPQaGJXi/PrIoSyzrPqE/jLNAy wEoHFDqZUy+a8ltpg8Vx70ngourgt7cUDFT1wzI2TX8V1eCC0xmkaxf1nU34N0GVYB6Y Us7PptSKaSJnGrIhTJtwTWiMtagnwsYdOPiElR0X8O8VKzaiZam538NLqV/4J7si/HW3 Rh7A== X-Gm-Message-State: AOJu0Yy6FwxpFxVwZq7uvyPqzg2oexly4q7qFdO+a5nQj7ZRggsOfH1a M9OP351LvnWR6M2IBd7noiNmkFtpyKCnM2F9N9I= X-Received: by 2002:a17:902:db0b:b0:1cc:5833:cf5e with SMTP id m11-20020a170902db0b00b001cc5833cf5emr3872457plx.27.1699990020403; Tue, 14 Nov 2023 11:27:00 -0800 (PST) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id j18-20020a170902c3d200b001c728609574sm6052643plj.6.2023.11.14.11.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 11:27:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Subject: [PULL 3/3] target/sparc: Fix RETURN Date: Tue, 14 Nov 2023 11:26:56 -0800 Message-Id: <20231114192656.176451-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114192656.176451-1-richard.henderson@linaro.org> References: <20231114192656.176451-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Perform window restore before pc update. Required in order to recognize any window underflow trap with the current pc. Fixes: 86b82fe021f4 ("target/sparc: Move JMPL, RETT, RETURN to decodetree") Reported-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Tested-by: Mark Cave-Ayland Acked-by: Mark Cave-Ayland Signed-off-by: Richard Henderson --- target/sparc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 6fc333a6b8..9387299559 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -4096,12 +4096,12 @@ TRANS(RETT, 32, do_add_special, a, do_rett) static bool do_return(DisasContext *dc, int rd, TCGv src) { gen_check_align(dc, src, 3); + gen_helper_restore(tcg_env); gen_mov_pc_npc(dc); tcg_gen_mov_tl(cpu_npc, src); gen_address_mask(dc, cpu_npc); - gen_helper_restore(tcg_env); dc->npc = DYNAMIC_PC_LOOKUP; return true; }