From patchwork Wed Oct 9 00:04:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827240 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB0DBEDE for ; Wed, 9 Oct 2024 00:04:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432298; cv=none; b=TfL4+BHULCgRAK1A9OgRNqeYFvwcU++f6b3weaP7kPVyy+SkRUA+Wh0yKS+ODCIoaakwCDGYXKqYg4hg366hb/mc7kN4F3LcldyEOzv4YH2M8J/+GzNy1gG5FAT5+YRJBv9m8J74ELG2e7TwVTF3aKOZvpVHcX4jfqELMj+r00c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432298; c=relaxed/simple; bh=PX7UlEBJfxn1U/i74gDBl6847zXg+qyZ9No+NdNhsqk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HrRs1osdVmfcb+piup7iSMkr0l/IrQyMYBdw8HTDI1L7khvDpRz4C8eeYjO1yVEQkyPbr9okh7hTeyFQuw993lGm0bVPGtzQbXtuTsQjm1uC7X6OO9lgR2IzMyYLM3xiv3gLV+iBdWSKIRT4li3qm/HGBn1A6iQfYNVr2eiIH4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=uOMODJ6M; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uOMODJ6M" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20b1335e4e4so61473475ad.0 for ; Tue, 08 Oct 2024 17:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432296; x=1729037096; darn=vger.kernel.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=5sM2rASXzZfAaByCSG4X7yOvvA/fFZaOvGmejFsljDo=; b=uOMODJ6M7SmqcxrkEBcTuhY6TF/UH5rVVJoq+ACbFzipZCn/1Xn2XofpSd4brmiVF4 X0Dunej5Lb+fFzif0Qfn3RNpN+ootquLYKz7muHCLlTXe0pauJi3U8FdPnUlx6ngPGwY d5sboxHF6T3QtLsNa3Q7fCCpfs3sxKAuXy/kXV3gILB0BFK7o6AmoeSjJexGdu5EiJeq yGjGPVcXRdIeXVkxPhx3VZAccGp4sJ/3Vw7U/xvRs9yy1mobhb/WOd44D/S6a2KOGP3h Eah6s6S/NFTKO+JAQsvIBL2nL61QUeyVpopq8L21/BOHqR9+TKx4t9Vx2IHfSj2g5bj5 XQew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432296; x=1729037096; 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=5sM2rASXzZfAaByCSG4X7yOvvA/fFZaOvGmejFsljDo=; b=JuA8ANAiH9a6lEohopl03sU59C6lQF2PjVk076GvTckQN4AA33bkgBfI0dN1ARinMW SkbrL6zvTPIc59feM3KqOB+j/hEaFb1izdMuwVWBT/+b2SukkoGna9I61V9GjC/2e95P Q9FIP4dmKFyX9qgIuyPIbcE4dWqTmuDu0sTKjbBCc37OpGGc+6vXLVajA2KC5D3CVrFh 9tYSOucN8Ix8/HZeJn688EPyYVjO/rKcoe+dQ1NSSXojyrrXSB5dMlNOvnS7ur9rBmvJ ZJvUwkzWdwQFj8wpud4ukOExuDfP/jEEHySeqsOxPI7ZEpjzXz/OFdZjO8zc1NGrg86S /xcQ== X-Forwarded-Encrypted: i=1; AJvYcCWnOUNelJTw78f3CQuR+PNAoQH0JFEIabrBnsnG3FT/2fHWupKtj3rCkZSML6GPkAaHKDexylVn6OOH7ww=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5iGkAYDm7nu/o/Tl+Wog75liBbezrfi6cP9bhLo3Z2XRov4+a oYQROxHW3Z3rleWmbjMG4FyU+rfEMUaOraJrql3VA5dNGv6dE0COiirI2+HFMAw= X-Google-Smtp-Source: AGHT+IH2ZvMU4bGuSg+tDG+ztb5xg61iiZPQqytdtvNBcTuZ+zmK3VvxDZbtlEMK7wthugBWGqHljQ== X-Received: by 2002:a17:902:f685:b0:20c:5c37:e2c6 with SMTP id d9443c01a7336-20c6375b1ecmr12035995ad.11.1728432296270; Tue, 08 Oct 2024 17:04:56 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:04:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller Subject: [PATCH v3 01/20] accel/tcg: Assert noreturn from write-only page for atomics Date: Tue, 8 Oct 2024 17:04:34 -0700 Message-ID: <20241009000453.315652-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There should be no "just in case"; the page is already in the tlb, and known to be not readable. Reviewed-by: Helge Deller Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 117b516739..fd6459b695 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1852,10 +1852,9 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, /* * Since we don't support reads and writes to different * addresses, and we do have the proper page loaded for - * write, this shouldn't ever return. But just in case, - * handle via stop-the-world. + * write, this shouldn't ever return. */ - goto stop_the_world; + g_assert_not_reached(); } /* Collect tlb flags for read. */ tlb_addr |= tlbe->addr_read; From patchwork Wed Oct 9 00:04:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827241 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA81B36D for ; Wed, 9 Oct 2024 00:04:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432299; cv=none; b=BjNhKgTxjR9gM1EwQb7TxJOFgb5fYtxenac/hDO6+BbH0lUqkIhmuUKauEx9FnR+n5IvZJKmt8/6CAX/fjgAFDdWfcEnNEYrvXcLWEu3a2JeREsRiF8KQbtV92VbYLa7QTaC5IqDi23Lb+c/iK6V/bu0pTh+SpPX5HsfTfX8M84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432299; c=relaxed/simple; bh=a1CSXCD7k+F9Ou2TU5Nm8NV+PyJFOU0XPFFoAuBJNJY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MJ6PAkNLuC5ZSrhdpwB9euABlSqxjIj1/THR2cf7vuR9S/wAcZtmbf9HQDnf06dhaLHHnes3X5y3HALoun5tIFg8nwexm55wnKNS4OG95GRWZ+BEAOpa+sTlr7x+IgtP9ufCdPH7N5j9VvEpKgsIIlVsf9opLE/wK5kzFZ7WvtU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=degRnJmn; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="degRnJmn" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-20bc506347dso49904285ad.0 for ; Tue, 08 Oct 2024 17:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432297; x=1729037097; darn=vger.kernel.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=O9DVukvxY0Nz2lbOkkF1UGxIJ0HiyrlwFe+DiEN47Z4=; b=degRnJmnNtXsChKestLor01gj+gRp2n98J+0k7QkS9HG2D6K82bNFK8ZJso5f7NHzw fV/ajPFdCm6oqcGMBKW/a0IVpjO/Hb8v6q30NpXnpLn4QO+UDbxNBMDuzq/jjpqrtEEw hEX7IwgDUya85OchnzeXzqVJ38cHXfZIa6jgX/uoQlZCZ4b+w4aoNrEg3mcnOfU9iEn9 CjRCHD7GPh06mPOdHVkgmoTdhJnAkzlrXhkyqfpgIAO82ES6BH+E0GIWk737+oVDT6sd gR4inrpzGU8Td69+WWTVu3KhnR7wsMUTCkWaGeUWqyyZGKymIoREzd+P4I4JgYVdmv/4 GJrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432297; x=1729037097; 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=O9DVukvxY0Nz2lbOkkF1UGxIJ0HiyrlwFe+DiEN47Z4=; b=SkiZbU2hnearelHnQjYaGjL7n85Y+4PI2wSL5X5CqTlvDcXmzGHjeyEOP38c6lr0do cyw5jVokb9EEZGsHhI4L8CZq0VmM3zhLDukDc8on2hZWX960l3tDUEOm9jrnVTyb2K6f tLrm2xTsL+B22u6j+URl7RcxljLYlXSeIqXmRN11f7oZwO5inRcPC95b1DgNGjn3J7L6 D0g9jJLfrCSP13kDrDefFbeohMvjorkln3bPNTDNleOHPotrI+KzBwPzsnKa5MEQtG0i a83aolWKMaWDLCmZoodSgKW6HlSzrrnzcYVO4IbswEDZ1UdroNUxWARz+Cpd1frecvrW i+Qw== X-Forwarded-Encrypted: i=1; AJvYcCU69l+C/MXmipn7/kwZYtC3P8qRvnpHl4mb8o1KKYrpuOIDJqSQfObDREQJPwejP+zndSCMNnqo1PyelGI=@vger.kernel.org X-Gm-Message-State: AOJu0YyjJvEMzWWYCjRhQgtxqTz5cfkfAOCSegT9n1d8hmsEKCJistoF ZVZWq3OVZIzg95etuLG94a82j5fR5yT0zPriv0qjtm6iusc+r7+rG+7uK2ntWfU= X-Google-Smtp-Source: AGHT+IELfN0bakgT3mk/GTecwW46dkwTT2ygCiT/BAX/1818Ov/crY2+v9Y6lIuiJxQlQfEPFhy1uA== X-Received: by 2002:a17:902:c40b:b0:20b:bf17:e497 with SMTP id d9443c01a7336-20c63780107mr10371935ad.46.1728432297083; Tue, 08 Oct 2024 17:04:57 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:04:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 02/20] include/exec/memop: Move get_alignment_bits from tcg.h Date: Tue, 8 Oct 2024 17:04:35 -0700 Message-ID: <20241009000453.315652-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This function is specific to MemOp, not TCG in general. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/memop.h | 23 +++++++++++++++++++++++ include/tcg/tcg.h | 23 ----------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/exec/memop.h b/include/exec/memop.h index f881fe7af4..97720a8ee7 100644 --- a/include/exec/memop.h +++ b/include/exec/memop.h @@ -170,4 +170,27 @@ static inline bool memop_big_endian(MemOp op) return (op & MO_BSWAP) == MO_BE; } +/** + * get_alignment_bits + * @memop: MemOp value + * + * Extract the alignment size from the memop. + */ +static inline unsigned get_alignment_bits(MemOp memop) +{ + unsigned a = memop & MO_AMASK; + + if (a == MO_UNALN) { + /* No alignment required. */ + a = 0; + } else if (a == MO_ALIGN) { + /* A natural alignment requirement. */ + a = memop & MO_SIZE; + } else { + /* A specific alignment requirement. */ + a = a >> MO_ASHIFT; + } + return a; +} + #endif diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 21d5884741..824fb3560d 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -281,29 +281,6 @@ static inline int tcg_type_size(TCGType t) return 4 << i; } -/** - * get_alignment_bits - * @memop: MemOp value - * - * Extract the alignment size from the memop. - */ -static inline unsigned get_alignment_bits(MemOp memop) -{ - unsigned a = memop & MO_AMASK; - - if (a == MO_UNALN) { - /* No alignment required. */ - a = 0; - } else if (a == MO_ALIGN) { - /* A natural alignment requirement. */ - a = memop & MO_SIZE; - } else { - /* A specific alignment requirement. */ - a = a >> MO_ASHIFT; - } - return a; -} - typedef tcg_target_ulong TCGArg; /* Define type and accessor macros for TCG variables. From patchwork Wed Oct 9 00:04:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827242 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4527383 for ; Wed, 9 Oct 2024 00:04:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432300; cv=none; b=GC99X8u0wIr7+5PlGylPkpDaRTpJO5v310cYILzAUJlIo4hiJ5/g09SCluNgUXJd3pJAtwM67IKT8qUNBqEsMgdfmak2hAKRALa2a+tjKvFcjwLablwMoNt+95I4L7CFA1QfgIXErjHSD5JHWS8oMe1212QgSp9cQf6FwITl66M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432300; c=relaxed/simple; bh=w/QOzsKw7a4vNlXl6cbX1MjiXaOrHXwj8J7K5e02kq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uMfg6UCNayN7Xpml9RMjOO+Yw6SxmF5oDWA1g1EElBc9A6ZS17YIntSlKLd/Q7a8/zB118g6AKpmwhy3+vqA0MyYKyfO31uWqoakjh6A15WQ2dQXAmnIIOnOim2l8MNp5jA1j3W33YmsR1ai1QUEWWuvhrOKkX8/CH2vea8HHU4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=KabXe3J8; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KabXe3J8" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-20b84bfbdfcso2394235ad.0 for ; Tue, 08 Oct 2024 17:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432298; x=1729037098; darn=vger.kernel.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=9LebsJbt4uExwr4Anb+4jbY7Oq0PbwNNghgu5qGnqlk=; b=KabXe3J8jK6d3XANEiZGDqsRizUgucfqvPTS4gchIluTNRF64RZpm/CFfuXspbC0WA n1SJ1vWni+TzaEmmYMzxI9iAy1v8EiCCe2dcniAMUQRVAclYgftmnyVgDNBcrB7Yyy4U qISsQAS38VdUncWhPMYz2WhLsxFQ3986i1jUUfvCvPp8IPiesgkCNyMhpEFki2fTlVA3 ydmCdwTrZDJwGJPo8q6p+02N/L2Aa5Mh0sjakbeX/7onL4EcgaT7+ltJnEecmQApj1E+ PYaL2rRwuJ+3INGTfhJWDzYEJJB60z0AAUQrMJIDd291IK3U4TIjKojz3yV2k51lLCP5 iYcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432298; x=1729037098; 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=9LebsJbt4uExwr4Anb+4jbY7Oq0PbwNNghgu5qGnqlk=; b=XB/oMO+fQBkHRzwEYjvm5E4HR1cEHr9/RiuopnUIpx27fkGkuzCNLtidDMnh/sm0AD oniqHlOPgwcEaZ0+ifEimmzBpKBfFpkpASjsTqsB+Gqz2DBaLSbJEZI1rcg28+UOyO75 xph0NiwnpvQlcWv0Zs9LhiIyynXn2aPDJnF/Jagiotnvoy0wYYiP7iyDi3tkwljWTu6M FrDaDXy5LrI4zn3Wf93U4Y6Vr26l4Bh5RwdeJvmgl3R0d8szl+rrkVhmZcoavtTCGt53 eNIFTbnfyv+nVl9z5gY8Sk5sH2c1NMGE+u8uP2LakCstzQ6p7Ibo63WOIHLuDWbndA/t ohaw== X-Forwarded-Encrypted: i=1; AJvYcCWFlOfRsXdrFkxeKI8uSXpB7e2TwvDw+arXWqfGsJYH2MPNG6Kf0E3X7XR3k0bQj1/5GsKHd6Qr4p5PkeM=@vger.kernel.org X-Gm-Message-State: AOJu0YzsHB7v5Iw/hX/dLktKZEzajGgjpo64lKDDPKNjbejUsMeV7KHJ jAb3ydqYyLky8x7INPqwXQHzO5/NXaDCUNe5HBkCmup2xM4ZdhWMSzmZCbl2qQQ= X-Google-Smtp-Source: AGHT+IFrjf/KG6jW0dXe87Xq6SyttisiiLp3ocVOdfABD+rqesa5TS+vrbt3d454eeR29R+9AWd9wA== X-Received: by 2002:a17:903:41cc:b0:206:b5b8:25dd with SMTP id d9443c01a7336-20c6352cdd6mr12193455ad.23.1728432298141; Tue, 08 Oct 2024 17:04:58 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:04:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 03/20] include/exec/memop: Rename get_alignment_bits Date: Tue, 8 Oct 2024 17:04:36 -0700 Message-ID: <20241009000453.315652-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rename to use "memop_" prefix, like other functions that operate on MemOp. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/memop.h | 4 ++-- accel/tcg/cputlb.c | 4 ++-- accel/tcg/user-exec.c | 4 ++-- target/arm/tcg/translate-a64.c | 4 ++-- target/xtensa/translate.c | 2 +- tcg/tcg-op-ldst.c | 6 +++--- tcg/tcg.c | 2 +- tcg/arm/tcg-target.c.inc | 4 ++-- tcg/sparc64/tcg-target.c.inc | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/exec/memop.h b/include/exec/memop.h index 97720a8ee7..f53bf618c6 100644 --- a/include/exec/memop.h +++ b/include/exec/memop.h @@ -171,12 +171,12 @@ static inline bool memop_big_endian(MemOp op) } /** - * get_alignment_bits + * memop_alignment_bits: * @memop: MemOp value * * Extract the alignment size from the memop. */ -static inline unsigned get_alignment_bits(MemOp memop) +static inline unsigned memop_alignment_bits(MemOp memop) { unsigned a = memop & MO_AMASK; diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index fd6459b695..a975fe5f89 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1709,7 +1709,7 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, tcg_debug_assert(l->mmu_idx < NB_MMU_MODES); /* Handle CPU specific unaligned behaviour */ - a_bits = get_alignment_bits(l->memop); + a_bits = memop_alignment_bits(l->memop); if (addr & ((1 << a_bits) - 1)) { cpu_unaligned_access(cpu, addr, type, l->mmu_idx, ra); } @@ -1797,7 +1797,7 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, { uintptr_t mmu_idx = get_mmuidx(oi); MemOp mop = get_memop(oi); - int a_bits = get_alignment_bits(mop); + int a_bits = memop_alignment_bits(mop); uintptr_t index; CPUTLBEntry *tlbe; vaddr tlb_addr; diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 7ddc47b0ba..08a6df9987 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -959,7 +959,7 @@ void page_reset_target_data(target_ulong start, target_ulong last) { } static void *cpu_mmu_lookup(CPUState *cpu, vaddr addr, MemOp mop, uintptr_t ra, MMUAccessType type) { - int a_bits = get_alignment_bits(mop); + int a_bits = memop_alignment_bits(mop); void *ret; /* Enforce guest required alignment. */ @@ -1241,7 +1241,7 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, int size, uintptr_t retaddr) { MemOp mop = get_memop(oi); - int a_bits = get_alignment_bits(mop); + int a_bits = memop_alignment_bits(mop); void *ret; /* Enforce guest required alignment. */ diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 071b6349fc..ec0b1ee252 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -294,7 +294,7 @@ static TCGv_i64 gen_mte_check1_mmuidx(DisasContext *s, TCGv_i64 addr, desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); - desc = FIELD_DP32(desc, MTEDESC, ALIGN, get_alignment_bits(memop)); + desc = FIELD_DP32(desc, MTEDESC, ALIGN, memop_alignment_bits(memop)); desc = FIELD_DP32(desc, MTEDESC, SIZEM1, memop_size(memop) - 1); ret = tcg_temp_new_i64(); @@ -326,7 +326,7 @@ TCGv_i64 gen_mte_checkN(DisasContext *s, TCGv_i64 addr, bool is_write, desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); - desc = FIELD_DP32(desc, MTEDESC, ALIGN, get_alignment_bits(single_mop)); + desc = FIELD_DP32(desc, MTEDESC, ALIGN, memop_alignment_bits(single_mop)); desc = FIELD_DP32(desc, MTEDESC, SIZEM1, total_size - 1); ret = tcg_temp_new_i64(); diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 75b7bfda4c..f4da4a40f9 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -521,7 +521,7 @@ static MemOp gen_load_store_alignment(DisasContext *dc, MemOp mop, mop |= MO_ALIGN; } if (!option_enabled(dc, XTENSA_OPTION_UNALIGNED_EXCEPTION)) { - tcg_gen_andi_i32(addr, addr, ~0 << get_alignment_bits(mop)); + tcg_gen_andi_i32(addr, addr, ~0 << memop_alignment_bits(mop)); } return mop; } diff --git a/tcg/tcg-op-ldst.c b/tcg/tcg-op-ldst.c index 23dc807f11..a318011229 100644 --- a/tcg/tcg-op-ldst.c +++ b/tcg/tcg-op-ldst.c @@ -45,7 +45,7 @@ static void check_max_alignment(unsigned a_bits) static MemOp tcg_canonicalize_memop(MemOp op, bool is64, bool st) { - unsigned a_bits = get_alignment_bits(op); + unsigned a_bits = memop_alignment_bits(op); check_max_alignment(a_bits); @@ -559,7 +559,7 @@ static void tcg_gen_qemu_ld_i128_int(TCGv_i128 val, TCGTemp *addr, TCGv_i64 ext_addr = NULL; TCGOpcode opc; - check_max_alignment(get_alignment_bits(memop)); + check_max_alignment(memop_alignment_bits(memop)); tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); /* In serial mode, reduce atomicity. */ @@ -676,7 +676,7 @@ static void tcg_gen_qemu_st_i128_int(TCGv_i128 val, TCGTemp *addr, TCGv_i64 ext_addr = NULL; TCGOpcode opc; - check_max_alignment(get_alignment_bits(memop)); + check_max_alignment(memop_alignment_bits(memop)); tcg_gen_req_mo(TCG_MO_ST_LD | TCG_MO_ST_ST); /* In serial mode, reduce atomicity. */ diff --git a/tcg/tcg.c b/tcg/tcg.c index 34e3056380..5decd83cf4 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -5506,7 +5506,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) static TCGAtomAlign atom_and_align_for_opc(TCGContext *s, MemOp opc, MemOp host_atom, bool allow_two_ops) { - MemOp align = get_alignment_bits(opc); + MemOp align = memop_alignment_bits(opc); MemOp size = opc & MO_SIZE; MemOp half = size ? size - 1 : 0; MemOp atom = opc & MO_ATOM_MASK; diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 3de5f50b62..56072d89a2 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1587,7 +1587,7 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, TCGReg datalo, tcg_debug_assert((datalo & 1) == 0); tcg_debug_assert(datahi == datalo + 1); /* LDRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >= MO_64) { + if (memop_alignment_bits(opc) >= MO_64) { if (h.index < 0) { tcg_out_ldrd_8(s, h.cond, datalo, h.base, 0); break; @@ -1691,7 +1691,7 @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg datalo, tcg_debug_assert((datalo & 1) == 0); tcg_debug_assert(datahi == datalo + 1); /* STRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >= MO_64) { + if (memop_alignment_bits(opc) >= MO_64) { if (h.index < 0) { tcg_out_strd_8(s, h.cond, datalo, h.base, 0); } else { diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index 176c98740b..32f9ec24b5 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -1133,7 +1133,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, * Otherwise, test for at least natural alignment and defer * everything else to the helper functions. */ - if (s_bits != get_alignment_bits(opc)) { + if (s_bits != memop_alignment_bits(opc)) { tcg_debug_assert(check_fit_tl(a_mask, 13)); tcg_out_arithi(s, TCG_REG_G0, addr_reg, a_mask, ARITH_ANDCC); From patchwork Wed Oct 9 00:04:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827243 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C85ED801 for ; Wed, 9 Oct 2024 00:04:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432301; cv=none; b=Po/d/jp34kgL+mSLMuWId8XMiSz4UbHF8bxx76u64utwtri5+O8bkpv9zZM5ROn7Ex3JErsRz5+wB/37XMthtcu2PvtnLPJVww6utUIBD47AvFsFOFIxqauQtxrHQTC2MTgSbRsJayZ8umdJzLwcxDTv/N2u24/ZivSzXkWoghw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432301; c=relaxed/simple; bh=/5quf5/LQWTajw7j7C9ADHG4pkyvLf0t+1qUD3vWmyk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QvxA/dTvv/4LLlMaM2ofwgEyi+eJ0yFeQkSciwWHaNfHBjbj3nqNiQMuIgTdyw42kRRgeMpXr4aDgIvmG9GZxIF7iZ0cBsw3cJCC1h7ySfAN1ZX6zybLnMVNld+IBSvBtIZrf95ZRDY9Y8GK4FvI7oWECN8hKYgwNqdE4G+qOrI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ju5Fvoz4; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ju5Fvoz4" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20b90984971so64136035ad.3 for ; Tue, 08 Oct 2024 17:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432299; x=1729037099; darn=vger.kernel.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=hoQpjuwa20HwjACHrMlYHXe57YCg2K0w30eV5HVGvRc=; b=ju5Fvoz431FP2AWU+mBRv9INOoUQHmRsFVEbTeeL89LgO62TWkrrpd90lohZbBHYc2 3GwaSKF/exzFbcFq4VMZ/IF5+0qYkvjVVb2LELCAp4zJvzENKhKZQuHQWCdhNmOUP8rQ LFGqG6oIAyNE1qRdha/f05VZY0eFEantIypMlZtIJiUMbPkhVc9Ji2p9x6L/Wb4fUsAs bURcOIYFWljvcIDD1P3ca7b73MbGdn80pAFbp6SgTyiuglJp+zAlbbdBiPWSFgWc1IFE 7/AT8dcZUZ6KEjlNZuG5iR6Rw9FfKJE5Elx3s4M7qqfxN6fT7eBQmh3vDIg9M1wLniqR 6hFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432299; x=1729037099; 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=hoQpjuwa20HwjACHrMlYHXe57YCg2K0w30eV5HVGvRc=; b=CcKQw3gKXsUjGq1u1pR5rb2E2+iGLC2Uf8TY1wRsBtMuN82oQLUHEkSuA/A+Czi4du Bj+oSZ8IW1t46N4nBHHvipz+aWH5SFq9fO5N2zVTlsNgJCuRjuWht+yrzXJSwgoE3iLw dIWYo0AxhGULjsqvIWbev36rmEiAQeRPebRPNlnOd9xK68FFHde8f9PGJw0clVrWm8gB 6S5g/plcnPYoR1RJEb3yMB9VKcXKZnGfRkYAuIUGU6E5z70fqFT6m793n7qOIBxwlnp/ 4RZ7QC5Cf+K7ZUHzp1fmjh8huemUnAEjzBaAGcxArcS5CZc3cOLJk5mGeGboOHAsv5iR f7xQ== X-Forwarded-Encrypted: i=1; AJvYcCXBLbfUWasyVxt8HMZAmWuZwn+g1192YG5I4fVDRT0sqlRZpCoyJxp0Kk3MRZ+1iJt9HaGN16ERPPKWi+c=@vger.kernel.org X-Gm-Message-State: AOJu0Yyg/pmoQX/q7j2I98yxq5bA5j5vsXG3r66z0ApqlDoDcqM8ymeS n3oMENMNGlEkF9S8ZL5x9tBtDjPivUTg76W1Qimo8eGRyoLgNWkoY6aJFE2MtuU= X-Google-Smtp-Source: AGHT+IEeu9+lnXWIBhz7pgvstBsOBX6KI79/ZD6KPp8fSOXLhjN4UEVyBQB1oHIG/Wwjwoi0un6x8Q== X-Received: by 2002:a17:903:2b05:b0:20b:6d8c:463 with SMTP id d9443c01a7336-20c637557d0mr12308135ad.35.1728432299121; Tue, 08 Oct 2024 17:04:59 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:04:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller Subject: [PATCH v3 04/20] include/exec/memop: Introduce memop_atomicity_bits Date: Tue, 8 Oct 2024 17:04:37 -0700 Message-ID: <20241009000453.315652-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Split out of mmu_lookup. Reviewed-by: Helge Deller Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/exec/memop.h | 24 ++++++++++++++++++++++++ accel/tcg/cputlb.c | 16 ++-------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/include/exec/memop.h b/include/exec/memop.h index f53bf618c6..b699bf7688 100644 --- a/include/exec/memop.h +++ b/include/exec/memop.h @@ -193,4 +193,28 @@ static inline unsigned memop_alignment_bits(MemOp memop) return a; } +/* + * memop_atomicity_bits: + * @memop: MemOp value + * + * Extract the atomicity size from the memop. + */ +static inline unsigned memop_atomicity_bits(MemOp memop) +{ + unsigned size = memop & MO_SIZE; + + switch (memop & MO_ATOM_MASK) { + case MO_ATOM_NONE: + size = MO_8; + break; + case MO_ATOM_IFALIGN_PAIR: + case MO_ATOM_WITHIN16_PAIR: + size = size ? size - 1 : 0; + break; + default: + break; + } + return size; +} + #endif diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index a975fe5f89..35cda1e2b0 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1767,20 +1767,8 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, * Device memory type require alignment. */ if (unlikely(flags & TLB_CHECK_ALIGNED)) { - MemOp size = l->memop & MO_SIZE; - - switch (l->memop & MO_ATOM_MASK) { - case MO_ATOM_NONE: - size = MO_8; - break; - case MO_ATOM_IFALIGN_PAIR: - case MO_ATOM_WITHIN16_PAIR: - size = size ? size - 1 : 0; - break; - default: - break; - } - if (addr & ((1 << size) - 1)) { + a_bits = memop_atomicity_bits(l->memop); + if (addr & ((1 << a_bits) - 1)) { cpu_unaligned_access(cpu, addr, type, l->mmu_idx, ra); } } From patchwork Wed Oct 9 00:04:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827244 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA85A383 for ; Wed, 9 Oct 2024 00:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432302; cv=none; b=d3BNkEM+Omg6kLxwB0BldPpu9T185TGR0Hmvz+7nBvH5ShmbbTLmpH0Y2tDQ+3YNixZVGER6vX7JZYvJqPwzsCWLE0yE2p7gDimkLfliK1y+lD0gFdA4SUG+25HoeUdbxkEeivB128YGPnzUf63dL581whhUZAlmmEqxZDejplo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432302; c=relaxed/simple; bh=tgGF/7beY7hrwgznY4FXToX4WNlmLl9Ww7iwIdlH7Gk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F6oBuzsOBs6kNQIM+i3oHZHvlinmDhw3j7zrzmUZlj1oARlipOulc5GgGZydtNrvuDxQhzBrXp4Z58sX7+1Zgg7Pk0I3sK0jejrKgamlBe9qTZ/fFGvvWILceWuTZ9NLPZNooffkR0yZ7C/KpuUUJiqkc1OA5z4UHpD/Cj65bx0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jF2WV2i2; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jF2WV2i2" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20b0b2528d8so70927565ad.2 for ; Tue, 08 Oct 2024 17:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432300; x=1729037100; darn=vger.kernel.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=KRlC3mms3e9Sb+Qb/UGEoW53IughvKHiILVrUessrrs=; b=jF2WV2i2+T7xDbiJNED6vxZW7FmsDs1MjmHcp1Fw+8tjfNklBYBWLT0z+v3GVm12+R He/TZvvRPoZSLCGlsPxkcWdXIWtF7lvE/uC2PlULsRwhbsrRzHLRzQJpgq2aM0WSUjjr cwnF1nx/YslTas3xtOm7ik9/X2LPJPpviz+rQO6PfKcLDPeoVpL3hkiNJuciAnCESM2Q XBjUlMjNWTchdxhuPUWAOqMQWqI5WZtRoBkScjZFC8PPJrz3bk5FlQK3B74sy6of7r8T HUKFG55tEM98RVjHbQ7FuBVZd1whCkr2yrV7d02bqbPZwijM6lmaCC8EkvMPDdTNLVCX 0RBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432300; x=1729037100; 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=KRlC3mms3e9Sb+Qb/UGEoW53IughvKHiILVrUessrrs=; b=B1UBu9whZRlD7XmaR4ip4kjRsDine2VAwkA1lVi5f7jdOC6YcRnsYZVggGxsKbKMxl tO+syR1YrV/wJuYoSVMEzx5qfnf4tJFUIbwvR16xAblWP65uMv7KvaQevPPh0Wfy2f+j oOkxUE7ZjHMbyxyVh7Pb431XGPes0qaicb3aysIbSWpzC7FGGbIjVdELazuTEJtepT+f 0SoHa3P387D34Uh/zpALGDzkVoaInXcWfF9Hy/OStGxjkyNc/b+LNeQfhiEjzum/bApE v0srwx4odKVWuf3/3an9hhvuVjs8xhuYtFLlYvPE5oXaLgf3tEoxUW9SPppIryZIKndB a0iw== X-Forwarded-Encrypted: i=1; AJvYcCXN2uoL6czVsb+sQJ/sV1JBWI/5DQfDe48B/OnULbz7UivsX54lO7eQGZAW0EucB8Gx6skp9Z0L9HQhpAI=@vger.kernel.org X-Gm-Message-State: AOJu0Yxd3dQytTb6mYK2lTLMZNIQXBp0N0bC7/+iZW3WLhXjkyoI2Ug+ K51VCdzOjj0yg/BV4b4a2lfvW++DAGtK5H2lKmWJlnB9Wh5tgpMrhxQtz2NexLE= X-Google-Smtp-Source: AGHT+IFCFvVKxRyLlvfGXYLtSu9ozN9PdneS174Hz9Cj7lMpmt/cbo6+LfjS0UmFUu6tz4mWEHkH6A== X-Received: by 2002:a17:903:98b:b0:208:b468:db21 with SMTP id d9443c01a7336-20c63748357mr13630815ad.30.1728432299990; Tue, 08 Oct 2024 17:04:59 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:04:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH v3 05/20] accel/tcg: Add TCGCPUOps.tlb_fill_align Date: Tue, 8 Oct 2024 17:04:38 -0700 Message-ID: <20241009000453.315652-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a new callback to handle softmmu paging. Return the page details directly, instead of passing them indirectly to tlb_set_page. Handle alignment simultaneously with paging so that faults are handled with target-specific priority. Route all calls the two hooks through a tlb_fill_align function local to cputlb.c. As yet no targets implement the new hook. As yet cputlb.c does not use the new alignment check. Signed-off-by: Richard Henderson Reviewed-by: Helge Deller Reviewed-by: Peter Maydell --- include/hw/core/cpu.h | 4 +-- include/hw/core/tcg-cpu-ops.h | 26 +++++++++++++++ include/qemu/typedefs.h | 1 + accel/tcg/cputlb.c | 61 ++++++++++++++++++++++------------- 4 files changed, 67 insertions(+), 25 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 04e9ad4996..d21a24c82f 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -205,7 +205,7 @@ struct CPUClass { * so the layout is not as critical as that of CPUTLBEntry. This is * also why we don't want to combine the two structs. */ -typedef struct CPUTLBEntryFull { +struct CPUTLBEntryFull { /* * @xlat_section contains: * - in the lower TARGET_PAGE_BITS, a physical section number @@ -261,7 +261,7 @@ typedef struct CPUTLBEntryFull { bool guarded; } arm; } extra; -} CPUTLBEntryFull; +}; /* * Data elements that are per MMU mode, minus the bits accessed by diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index 34318cf0e6..c932690621 100644 --- a/include/hw/core/tcg-cpu-ops.h +++ b/include/hw/core/tcg-cpu-ops.h @@ -13,6 +13,7 @@ #include "exec/breakpoint.h" #include "exec/hwaddr.h" #include "exec/memattrs.h" +#include "exec/memop.h" #include "exec/mmu-access-type.h" #include "exec/vaddr.h" @@ -131,6 +132,31 @@ struct TCGCPUOps { * same function signature. */ bool (*cpu_exec_halt)(CPUState *cpu); + /** + * @tlb_fill_align: Handle a softmmu tlb miss + * @cpu: cpu context + * @out: output page properties + * @addr: virtual address + * @access_type: read, write or execute + * @mmu_idx: mmu context + * @memop: memory operation for the access + * @size: memory access size, or 0 for whole page + * @probe: test only, no fault + * @ra: host return address for exception unwind + * + * If the access is valid, fill in @out and return true. + * Otherwise if probe is true, return false. + * Otherwise raise and exception and do not return. + * + * The alignment check for the access is deferred to this hook, + * so that the target can determine the priority of any alignment + * fault with respect to other potential faults from paging. + * Zero may be passed for @memop to skip any alignment check + * for non-memory-access operations such as probing. + */ + bool (*tlb_fill_align)(CPUState *cpu, CPUTLBEntryFull *out, vaddr addr, + MMUAccessType access_type, int mmu_idx, + MemOp memop, int size, bool probe, uintptr_t ra); /** * @tlb_fill: Handle a softmmu tlb miss * diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 9d222dc376..3d84efcac4 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -40,6 +40,7 @@ typedef struct ConfidentialGuestSupport ConfidentialGuestSupport; typedef struct CPUArchState CPUArchState; typedef struct CPUPluginState CPUPluginState; typedef struct CPUState CPUState; +typedef struct CPUTLBEntryFull CPUTLBEntryFull; typedef struct DeviceState DeviceState; typedef struct DirtyBitmapSnapshot DirtyBitmapSnapshot; typedef struct DisasContextBase DisasContextBase; diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 35cda1e2b0..d72f454e9e 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1221,22 +1221,35 @@ void tlb_set_page(CPUState *cpu, vaddr addr, } /* - * Note: tlb_fill() can trigger a resize of the TLB. This means that all of the - * caller's prior references to the TLB table (e.g. CPUTLBEntry pointers) must - * be discarded and looked up again (e.g. via tlb_entry()). + * Note: tlb_fill_align() can trigger a resize of the TLB. + * This means that all of the caller's prior references to the TLB table + * (e.g. CPUTLBEntry pointers) must be discarded and looked up again + * (e.g. via tlb_entry()). */ -static void tlb_fill(CPUState *cpu, vaddr addr, int size, - MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +static bool tlb_fill_align(CPUState *cpu, vaddr addr, MMUAccessType type, + int mmu_idx, MemOp memop, int size, + bool probe, uintptr_t ra) { - bool ok; + const TCGCPUOps *ops = cpu->cc->tcg_ops; + CPUTLBEntryFull full; - /* - * This is not a probe, so only valid return is success; failure - * should result in exception + longjmp to the cpu loop. - */ - ok = cpu->cc->tcg_ops->tlb_fill(cpu, addr, size, - access_type, mmu_idx, false, retaddr); - assert(ok); + if (ops->tlb_fill_align) { + if (ops->tlb_fill_align(cpu, &full, addr, type, mmu_idx, + memop, size, probe, ra)) { + tlb_set_page_full(cpu, mmu_idx, addr, &full); + return true; + } + } else { + /* Legacy behaviour is alignment before paging. */ + if (addr & ((1u << memop_alignment_bits(memop)) - 1)) { + ops->do_unaligned_access(cpu, addr, type, mmu_idx, ra); + } + if (ops->tlb_fill(cpu, addr, size, type, mmu_idx, probe, ra)) { + return true; + } + } + assert(probe); + return false; } static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, @@ -1351,22 +1364,22 @@ static int probe_access_internal(CPUState *cpu, vaddr addr, if (!tlb_hit_page(tlb_addr, page_addr)) { if (!victim_tlb_hit(cpu, mmu_idx, index, access_type, page_addr)) { - if (!cpu->cc->tcg_ops->tlb_fill(cpu, addr, fault_size, access_type, - mmu_idx, nonfault, retaddr)) { + if (!tlb_fill_align(cpu, addr, access_type, mmu_idx, + 0, fault_size, nonfault, retaddr)) { /* Non-faulting page table read failed. */ *phost = NULL; *pfull = NULL; return TLB_INVALID_MASK; } - /* TLB resize via tlb_fill may have moved the entry. */ + /* TLB resize via tlb_fill_align may have moved the entry. */ index = tlb_index(cpu, mmu_idx, addr); entry = tlb_entry(cpu, mmu_idx, addr); /* * With PAGE_WRITE_INV, we set TLB_INVALID_MASK immediately, - * to force the next access through tlb_fill. We've just - * called tlb_fill, so we know that this entry *is* valid. + * to force the next access through tlb_fill_align. We've just + * called tlb_fill_align, so we know that this entry *is* valid. */ flags &= ~TLB_INVALID_MASK; } @@ -1613,7 +1626,7 @@ typedef struct MMULookupLocals { * * Resolve the translation for the one page at @data.addr, filling in * the rest of @data with the results. If the translation fails, - * tlb_fill will longjmp out. Return true if the softmmu tlb for + * tlb_fill_align will longjmp out. Return true if the softmmu tlb for * @mmu_idx may have resized. */ static bool mmu_lookup1(CPUState *cpu, MMULookupPageData *data, @@ -1631,7 +1644,8 @@ static bool mmu_lookup1(CPUState *cpu, MMULookupPageData *data, if (!tlb_hit(tlb_addr, addr)) { if (!victim_tlb_hit(cpu, mmu_idx, index, access_type, addr & TARGET_PAGE_MASK)) { - tlb_fill(cpu, addr, data->size, access_type, mmu_idx, ra); + tlb_fill_align(cpu, addr, access_type, mmu_idx, + 0, data->size, false, ra); maybe_resized = true; index = tlb_index(cpu, mmu_idx, addr); entry = tlb_entry(cpu, mmu_idx, addr); @@ -1821,8 +1835,8 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, if (!tlb_hit(tlb_addr, addr)) { if (!victim_tlb_hit(cpu, mmu_idx, index, MMU_DATA_STORE, addr & TARGET_PAGE_MASK)) { - tlb_fill(cpu, addr, size, - MMU_DATA_STORE, mmu_idx, retaddr); + tlb_fill_align(cpu, addr, MMU_DATA_STORE, mmu_idx, + 0, size, false, retaddr); index = tlb_index(cpu, mmu_idx, addr); tlbe = tlb_entry(cpu, mmu_idx, addr); } @@ -1836,7 +1850,8 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, * but addr_read will only be -1 if PAGE_READ was unset. */ if (unlikely(tlbe->addr_read == -1)) { - tlb_fill(cpu, addr, size, MMU_DATA_LOAD, mmu_idx, retaddr); + tlb_fill_align(cpu, addr, MMU_DATA_LOAD, mmu_idx, + 0, size, false, retaddr); /* * Since we don't support reads and writes to different * addresses, and we do have the proper page loaded for From patchwork Wed Oct 9 00:04:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827245 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38B79801 for ; Wed, 9 Oct 2024 00:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432303; cv=none; b=Uu1JfDqYsAzpZoNLaZE87ViTWb/6gaW+nGOx6aE82XvPaFC+0sHDZc4uv110Q6JGF5eAkF27eg9J2NiBpWThd1GX9MAqIk8CPyVcx4GCIU/RGxQ7MczphZT+jU3qzhFZJT4Ms56NAwZOFELQrW2Seb45iGhdpOEcJ8itxlByJC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432303; c=relaxed/simple; bh=JaamhqcjfOsrDiJPcnSELA9aOocOLFsRVupkPPO7N2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kvvm4a9huGWVNn0NSAhCyia5jiNhhuSgr6MvNZWx/n1zv+rukWcks3iG2C4Ov7zemX3oimj+pipySVoC489pyyvOSuIHt4kPK43VgNF+cFNAD9aCLT+KZaY4CNS2TOoJ04aCCq2W/w9LHQRk3XG10mzCwW4abkujc5YzdI/UNeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Wxn6wbLT; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Wxn6wbLT" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20b90984971so64136335ad.3 for ; Tue, 08 Oct 2024 17:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432301; x=1729037101; darn=vger.kernel.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=/dFojoXE4+jjskAlQVsQMp2S+E0WFZ4r9iQmpRIn1e0=; b=Wxn6wbLTqNhFqJYbli39iwnGnH2zUGVEG4tPHnZ01wh5c2NTkdncNiVmZTpyKwvI32 jQESycETlvT7+n7ZTklZPN/tcYIPbNroq1X+wEKMiEny3WYPw62vJPZTZpHoTy1ReNcz zMcaLhzJ5oyHs7U/HoqFjtB8L1VOBThCnYyyMA1oW+fwajojl8vHQmT9hNiK9wlx5DrL trtkobOezilU/iQowcZJ+SU55Zjut7FYfUp/wiK6XP0Q3fXa/O64yOSs7gaa8kOIbPUo kjSecx8zCspVrN75Y4aiEWNfAR1ya49Gz0rKRzv2QB5LwutF32qGwLVM8atVBX6IYx2z Yy3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432301; x=1729037101; 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=/dFojoXE4+jjskAlQVsQMp2S+E0WFZ4r9iQmpRIn1e0=; b=KZjyF82ET3xxSAROhEGlXWVP8cgnGayX5lqJXOi4n2pK+SKaofAr6RxsSKmop7QSm4 P74XE0Xaa4hL8K7uIxCu7y+8sYMQjlHlU3bsP747GczOitoBDlzIL+XfTjbF1sU92atP JcaU7OVSCv5kN8Lm5Kf7lNPAfeGxhMa1lTZBquVIq+2hanqpJPlhzoLq30MGCyksiNj8 9fNQytRtRxR7qK036/67F9EWPUeVsUqI9nq1Pz2bY/uFnqKWMojAl8iEKVdLS323mhzk FiMSauadZlzynp8+sAOQhLqkKjbV/kAHZrLQUeM1ak4n1gMT9Mw490hkOnyoMQCUsxYK hvPg== X-Forwarded-Encrypted: i=1; AJvYcCWJrNpQ4yWdnYCETmbu1OeKP1L6ynLVyR3zypjnNtzL8o/3sBR20fMnZRvJq4NdTWTSnj2pUuJmhqmKVYY=@vger.kernel.org X-Gm-Message-State: AOJu0YwrJumyVKsYs0UVxDAoFozh19jcHt1sgTL11v3MaXR7WXqZJ3di XPfQhKhpCQFp64DtIDgs9PkCP1TJXbHmxUpKE7uvnREOseB/vXPF4TeQRcQhlkU= X-Google-Smtp-Source: AGHT+IEqHXg8mWURHcAfVqAuEFw3SPebibRlwH8KpqMvpctboOYhLIxxyQyaRkxFDrswJJ24vV5qqA== X-Received: by 2002:a17:903:32d0:b0:205:810a:190a with SMTP id d9443c01a7336-20c636f44famr10016545ad.2.1728432301297; Tue, 08 Oct 2024 17:05:01 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH v3 06/20] accel/tcg: Use the alignment test in tlb_fill_align Date: Tue, 8 Oct 2024 17:04:39 -0700 Message-ID: <20241009000453.315652-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When we have a tlb miss, defer the alignment check to the new tlb_fill_align hook. Move the existing alignment check so that we only perform it with a tlb hit. Signed-off-by: Richard Henderson Reviewed-by: Helge Deller --- accel/tcg/cputlb.c | 88 ++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index d72f454e9e..b76a4eac4e 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1620,6 +1620,7 @@ typedef struct MMULookupLocals { * mmu_lookup1: translate one page * @cpu: generic cpu state * @data: lookup parameters + * @memop: memory operation for the access, or 0 * @mmu_idx: virtual address context * @access_type: load/store/code * @ra: return address into tcg generated code, or 0 @@ -1629,7 +1630,7 @@ typedef struct MMULookupLocals { * tlb_fill_align will longjmp out. Return true if the softmmu tlb for * @mmu_idx may have resized. */ -static bool mmu_lookup1(CPUState *cpu, MMULookupPageData *data, +static bool mmu_lookup1(CPUState *cpu, MMULookupPageData *data, MemOp memop, int mmu_idx, MMUAccessType access_type, uintptr_t ra) { vaddr addr = data->addr; @@ -1645,7 +1646,7 @@ static bool mmu_lookup1(CPUState *cpu, MMULookupPageData *data, if (!victim_tlb_hit(cpu, mmu_idx, index, access_type, addr & TARGET_PAGE_MASK)) { tlb_fill_align(cpu, addr, access_type, mmu_idx, - 0, data->size, false, ra); + memop, data->size, false, ra); maybe_resized = true; index = tlb_index(cpu, mmu_idx, addr); entry = tlb_entry(cpu, mmu_idx, addr); @@ -1657,6 +1658,25 @@ static bool mmu_lookup1(CPUState *cpu, MMULookupPageData *data, flags = tlb_addr & (TLB_FLAGS_MASK & ~TLB_FORCE_SLOW); flags |= full->slow_flags[access_type]; + if (likely(!maybe_resized)) { + /* Alignment has not been checked by tlb_fill_align. */ + int a_bits = memop_alignment_bits(memop); + + /* + * This alignment check differs from the one above, in that this is + * based on the atomicity of the operation. The intended use case is + * the ARM memory type field of each PTE, where access to pages with + * Device memory type require alignment. + */ + if (unlikely(flags & TLB_CHECK_ALIGNED)) { + int at_bits = memop_atomicity_bits(memop); + a_bits = MAX(a_bits, at_bits); + } + if (unlikely(addr & ((1 << a_bits) - 1))) { + cpu_unaligned_access(cpu, addr, access_type, mmu_idx, ra); + } + } + data->full = full; data->flags = flags; /* Compute haddr speculatively; depending on flags it might be invalid. */ @@ -1713,7 +1733,6 @@ static void mmu_watch_or_dirty(CPUState *cpu, MMULookupPageData *data, static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, uintptr_t ra, MMUAccessType type, MMULookupLocals *l) { - unsigned a_bits; bool crosspage; int flags; @@ -1722,12 +1741,6 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, tcg_debug_assert(l->mmu_idx < NB_MMU_MODES); - /* Handle CPU specific unaligned behaviour */ - a_bits = memop_alignment_bits(l->memop); - if (addr & ((1 << a_bits) - 1)) { - cpu_unaligned_access(cpu, addr, type, l->mmu_idx, ra); - } - l->page[0].addr = addr; l->page[0].size = memop_size(l->memop); l->page[1].addr = (addr + l->page[0].size - 1) & TARGET_PAGE_MASK; @@ -1735,7 +1748,7 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, crosspage = (addr ^ l->page[1].addr) & TARGET_PAGE_MASK; if (likely(!crosspage)) { - mmu_lookup1(cpu, &l->page[0], l->mmu_idx, type, ra); + mmu_lookup1(cpu, &l->page[0], l->memop, l->mmu_idx, type, ra); flags = l->page[0].flags; if (unlikely(flags & (TLB_WATCHPOINT | TLB_NOTDIRTY))) { @@ -1754,8 +1767,8 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, * Lookup both pages, recognizing exceptions from either. If the * second lookup potentially resized, refresh first CPUTLBEntryFull. */ - mmu_lookup1(cpu, &l->page[0], l->mmu_idx, type, ra); - if (mmu_lookup1(cpu, &l->page[1], l->mmu_idx, type, ra)) { + mmu_lookup1(cpu, &l->page[0], l->memop, l->mmu_idx, type, ra); + if (mmu_lookup1(cpu, &l->page[1], 0, l->mmu_idx, type, ra)) { uintptr_t index = tlb_index(cpu, l->mmu_idx, addr); l->page[0].full = &cpu->neg.tlb.d[l->mmu_idx].fulltlb[index]; } @@ -1774,19 +1787,6 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, tcg_debug_assert((flags & TLB_BSWAP) == 0); } - /* - * This alignment check differs from the one above, in that this is - * based on the atomicity of the operation. The intended use case is - * the ARM memory type field of each PTE, where access to pages with - * Device memory type require alignment. - */ - if (unlikely(flags & TLB_CHECK_ALIGNED)) { - a_bits = memop_atomicity_bits(l->memop); - if (addr & ((1 << a_bits) - 1)) { - cpu_unaligned_access(cpu, addr, type, l->mmu_idx, ra); - } - } - return crosspage; } @@ -1799,34 +1799,18 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, { uintptr_t mmu_idx = get_mmuidx(oi); MemOp mop = get_memop(oi); - int a_bits = memop_alignment_bits(mop); uintptr_t index; CPUTLBEntry *tlbe; vaddr tlb_addr; void *hostaddr; CPUTLBEntryFull *full; + bool did_tlb_fill = false; tcg_debug_assert(mmu_idx < NB_MMU_MODES); /* Adjust the given return address. */ retaddr -= GETPC_ADJ; - /* Enforce guest required alignment. */ - if (unlikely(a_bits > 0 && (addr & ((1 << a_bits) - 1)))) { - /* ??? Maybe indicate atomic op to cpu_unaligned_access */ - cpu_unaligned_access(cpu, addr, MMU_DATA_STORE, - mmu_idx, retaddr); - } - - /* Enforce qemu required alignment. */ - if (unlikely(addr & (size - 1))) { - /* We get here if guest alignment was not requested, - or was not enforced by cpu_unaligned_access above. - We might widen the access and emulate, but for now - mark an exception and exit the cpu loop. */ - goto stop_the_world; - } - index = tlb_index(cpu, mmu_idx, addr); tlbe = tlb_entry(cpu, mmu_idx, addr); @@ -1836,7 +1820,8 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, if (!victim_tlb_hit(cpu, mmu_idx, index, MMU_DATA_STORE, addr & TARGET_PAGE_MASK)) { tlb_fill_align(cpu, addr, MMU_DATA_STORE, mmu_idx, - 0, size, false, retaddr); + mop, size, false, retaddr); + did_tlb_fill = true; index = tlb_index(cpu, mmu_idx, addr); tlbe = tlb_entry(cpu, mmu_idx, addr); } @@ -1859,6 +1844,23 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, */ g_assert_not_reached(); } + + /* Enforce guest required alignment, if not handled by tlb_fill_align. */ + if (!did_tlb_fill && (addr & ((1 << memop_alignment_bits(mop)) - 1))) { + cpu_unaligned_access(cpu, addr, MMU_DATA_STORE, mmu_idx, retaddr); + } + + /* Enforce qemu required alignment. */ + if (unlikely(addr & (size - 1))) { + /* + * We get here if guest alignment was not requested, or was not + * enforced by cpu_unaligned_access or tlb_fill_align above. + * We might widen the access and emulate, but for now + * mark an exception and exit the cpu loop. + */ + goto stop_the_world; + } + /* Collect tlb flags for read. */ tlb_addr |= tlbe->addr_read; From patchwork Wed Oct 9 00:04:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827246 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15D14383 for ; Wed, 9 Oct 2024 00:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432304; cv=none; b=jYS5B++F+8VgtCCDKLWp+3di6iFICdMzYhVLrPGNTVCiGwz3XKyhvOtp5/SWG4mTclMEIqgJQrllDn1KCtX31VzurEFsSDekQsZ7nsoV77kBezzyV4yFkUry7i9wf3Wg5WyuT9i3c0ccwCvbQBjisAFRrTeca/2/BaITxYzsdKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432304; c=relaxed/simple; bh=bQT9W9Nq8weSF+Om9R/l3gveO34JMzwI5GiDSjp/IE8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZzcNh3s2vB50LPY2+n9Bq9H5NWVmE+8H+4jQCUDLKyDiBnijmcC1Or7sqt8yOtF9yOPYwc/2czSyBRJaRPmVwVOHoef6layvm/rBCR3rvl/2SqTCByGoho3z1g5DVnJTpE8jzRQ+6jhLpswvjizbn0K0fI1GQuMe8VESQchIHmU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hqo6K/PU; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hqo6K/PU" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-20bc506347dso49904735ad.0 for ; Tue, 08 Oct 2024 17:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432302; x=1729037102; darn=vger.kernel.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=ZMaSkZRoz5YPXdGi4Fagk1yb2WqLYDqE0+TVeXDEoMY=; b=hqo6K/PUCjUaE+1IHAsrt2QI5iofUPX12PT/cbC3IfGxtmb9by7QjwvHDUzUoOcYKr GDNDpfc2/g7ICPdXqnRHP9R9LxGcaaiVuGQR4RB3C6yNfvi/IOemwag4jjwJu/HU5sCN 1D1J7VLcRXXOdIxNCmg12ojausL6IpBz12fDpJHkOaD28T67Qa1ihlAHPJeOFYcXKJs+ x8zogwD79MJ33R69eML7MMFWAtzFnxBJmdvYhjofwjoFXleifFgaDdyBSL8cKYSstuez 9aQANHZ1DPNHNKTQiZ5AkZAeRPt2inaVEilrbemyP9us96HQnWy8q07VOcAbOtTv/gee FJLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432302; x=1729037102; 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=ZMaSkZRoz5YPXdGi4Fagk1yb2WqLYDqE0+TVeXDEoMY=; b=uZ3YL1JxK6H+cSxYdwopzHCyVEixox9F6IumNP+Y4/Vtn3dGqpGBO+FEpHOuCfHrFT AIV56cKTAJqsAM5F/fNOig6fhVgFNtDWJ3BBB98oVTIQBjlfgzod75TqHRa84PhvusWe GeY06m/UZCL7oNMibBXcKn62c6E3HuSaMetvbG+nohi8m+798bl6xe+z1/26cd5uZkqL 7OlBvBiR+Lkm0FEGbky9zNDlyxRv5PIf23TFJwfYROooNFmJ0DfEtuoVGHY3oi831Vo8 PKFY+IJ0sHYOgklikGbts2Nvq54rMQAXxCzlUJGRGJzBMfwqALV3cac5hDge+NYxqfx1 WxJw== X-Forwarded-Encrypted: i=1; AJvYcCXfqHqQFHVznqqkGRvTTezFh05JkJOSROIKCampIMbpflwb8/jgACfuTSl4bUz0hT34j8O6zt8wN6ZNhHU=@vger.kernel.org X-Gm-Message-State: AOJu0YwoE/MoGYNRKEPx2cSTu5JcE5/JUPOy8JX+rQLTBea3B1xdRGbc BU6vgM5GAfzp3LdCMX5WHqAKiByIAeUxo+bljdXVfZSeAVax7CaHzr/fLlw0Uds= X-Google-Smtp-Source: AGHT+IH7ittC4fNcWZZnvUvR2MzaRIxXqIaW0oGTZ44MyvMuTJp+JuwMH0O7T03auchaNuRqnZyQ0w== X-Received: by 2002:a17:902:f54c:b0:20b:79cb:492f with SMTP id d9443c01a7336-20c63780152mr9718395ad.43.1728432302402; Tue, 08 Oct 2024 17:05:02 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 07/20] target/hppa: Add MemOp argument to hppa_get_physical_address Date: Tue, 8 Oct 2024 17:04:40 -0700 Message-ID: <20241009000453.315652-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Just add the argument, unused at this point. Zero is the safe do-nothing value for all callers. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/hppa/cpu.h | 2 +- target/hppa/int_helper.c | 2 +- target/hppa/mem_helper.c | 9 +++++---- target/hppa/op_helper.c | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index f4e051f176..526855f982 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -369,7 +369,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, void hppa_cpu_do_interrupt(CPUState *cpu); bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req); int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, - int type, hwaddr *pphys, int *pprot); + int type, MemOp mop, hwaddr *pphys, int *pprot); void hppa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index 391f32f27d..58695def82 100644 --- a/target/hppa/int_helper.c +++ b/target/hppa/int_helper.c @@ -167,7 +167,7 @@ void hppa_cpu_do_interrupt(CPUState *cs) vaddr = hppa_form_gva_psw(old_psw, env->iasq_f, vaddr); t = hppa_get_physical_address(env, vaddr, MMU_KERNEL_IDX, - 0, &paddr, &prot); + 0, 0, &paddr, &prot); if (t >= 0) { /* We can't re-load the instruction. */ env->cr[CR_IIR] = 0; diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index b984f730aa..a386c80fa4 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -197,7 +197,7 @@ static int match_prot_id64(CPUHPPAState *env, uint32_t access_id) } int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, - int type, hwaddr *pphys, int *pprot) + int type, MemOp mop, hwaddr *pphys, int *pprot) { hwaddr phys; int prot, r_prot, w_prot, x_prot, priv; @@ -340,7 +340,7 @@ hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) mmu_idx = (cpu->env.psw & PSW_D ? MMU_KERNEL_IDX : cpu->env.psw & PSW_W ? MMU_ABS_W_IDX : MMU_ABS_IDX); - excp = hppa_get_physical_address(&cpu->env, addr, mmu_idx, 0, + excp = hppa_get_physical_address(&cpu->env, addr, mmu_idx, 0, 0, &phys, &prot); /* Since we're translating for debugging, the only error that is a @@ -438,7 +438,8 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, break; } - excp = hppa_get_physical_address(env, addr, mmu_idx, a_prot, &phys, &prot); + excp = hppa_get_physical_address(env, addr, mmu_idx, a_prot, 0, + &phys, &prot); if (unlikely(excp >= 0)) { if (probe) { return false; @@ -678,7 +679,7 @@ target_ulong HELPER(lpa)(CPUHPPAState *env, target_ulong addr) hwaddr phys; int prot, excp; - excp = hppa_get_physical_address(env, addr, MMU_KERNEL_IDX, 0, + excp = hppa_get_physical_address(env, addr, MMU_KERNEL_IDX, 0, 0, &phys, &prot); if (excp >= 0) { if (excp == EXCP_DTLB_MISS) { diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 7f79196fff..744325969f 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -334,7 +334,7 @@ target_ulong HELPER(probe)(CPUHPPAState *env, target_ulong addr, } mmu_idx = PRIV_P_TO_MMU_IDX(level, env->psw & PSW_P); - excp = hppa_get_physical_address(env, addr, mmu_idx, 0, &phys, &prot); + excp = hppa_get_physical_address(env, addr, mmu_idx, 0, 0, &phys, &prot); if (excp >= 0) { cpu_restore_state(env_cpu(env), GETPC()); hppa_set_ior_and_isr(env, addr, MMU_IDX_MMU_DISABLED(mmu_idx)); From patchwork Wed Oct 9 00:04:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827247 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E04B4370 for ; Wed, 9 Oct 2024 00:05:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432305; cv=none; b=KfCobu5MTK/Vjtb1z34OdHkoNZiNt7oSpWyT91M5cmmXH+OTCZNCM2J0ZERgdxUfVV93KjrfiatYTRpkDnUB/d/jy/nbqPJBLNczL4MoYuXGc4wzcGkMJQXYnbwQLJh9frm9cZ1S956C3qeVnHOeivZNs48u3OlXZnSCOz3IQFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432305; c=relaxed/simple; bh=rnYo41mvVlDDfQYXpospuwu7o2xpyxok+A4G7sfAZJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qQMRvNz1wcEGXI5AZllUEDEg8LRzC/kJvWoTJPRBG3xOpix2HuouRYFk0sV35OKTy6La+jmqHc0GEFLibNu/SoyjpM5J5fn+p9Sw1dYVh/DUDNA53qcNV11cbf/DuzOkQHf/eEoCXoqPAC2unX/KkIXZacBe9dUYGgsWgVUxmHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=q2teZnpN; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="q2teZnpN" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20b90984971so64136525ad.3 for ; Tue, 08 Oct 2024 17:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432303; x=1729037103; darn=vger.kernel.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=jvwlrMz3Fk2P5q43/JWG8Wh7xLnVWB9wP6XAmMUyGN8=; b=q2teZnpNdCXnDw1irDTRwXj6OQLcS3agsIWbo3kkr0ecYmzkYk9fOAk6q3ZMF2yf0v ysaiVzLWyzd/AAwjAEC38uT8d6XEGKAb5x3q7Jw0mEd/ECcqHB4LlY4QYAvN9KByJf+f pjAOPnFBNZOnNgtQPWqDZdpgnQqw2TKk3FKP5TwQ1iL63pJ1Ms2ErPuTo8QEYOsQDpR+ XV7HbxM+hWiLNKXXkk6Mg8vkTMY4ZFuOi6sM3R3UsMqGoPVbIn5EYqdFDiigCLhs1sEx 0BtgT8v0BRYL1kVcYaX81L7x4cczdkdMQoRth/wqKtldn8XIFMXpT6U5l1Bpemt5JkWh +0XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432303; x=1729037103; 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=jvwlrMz3Fk2P5q43/JWG8Wh7xLnVWB9wP6XAmMUyGN8=; b=nR1AUuTBf9pU4RnzsYzmWyKh5WH6+JeYKpGKTqyn2IsjAkmbMJqrvgwcgtE0kgf8N6 ar9xTyN5rtOwjuNcVDlS3S/RDfJlPiu7lnj45/vSTwT+wk/Sst5I57uEps+PHhuAoB/o ciLXVkbJXLnEgU0b2cp7n1ajOEGWlDGXAXOQgPAXNSzng7t58fLqAv8bNtwKBCvJdrKf 2ELWnO3/cxUCHGoKld1IU6Zvdrpi44x9/ofOpLhOCA+Lt04hgvtEIbJQTDezGg3SBYIc ckPlUBDp6rEsfEwSJcccfDAc3jYVoGZtk3H+qRNywpGkWR/jA206tofN7udgSrIvsliq vu8g== X-Forwarded-Encrypted: i=1; AJvYcCV48OIgkgTcMzHXCpEYz2nFWYbYOoovG8pQsufuZXCwUlUc514WIndHyk8khGmLuD9VrMrUdVyHm/CLol8=@vger.kernel.org X-Gm-Message-State: AOJu0YznlSMjjzLNn4bFIVpImkFbhfC8ZoYfdlCi1fpWgaQNhpsyETRm uRYd5Z5ZApwveGmtHkm8H/daqfcsUa/Zccxqud8LoLlVSPmpuS18G1ArRn5tR+0= X-Google-Smtp-Source: AGHT+IEQN3Rl72pcmgLCTKgbIcOtLba1v+GzwtpoC9AF0fnEDdxLNrxqZqv2s5T7uD+5Iv4bbg/olQ== X-Received: by 2002:a17:903:2289:b0:20c:5263:247a with SMTP id d9443c01a7336-20c637809c9mr15713945ad.38.1728432303433; Tue, 08 Oct 2024 17:05:03 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller Subject: [PATCH v3 08/20] target/hppa: Perform access rights before protection id check Date: Tue, 8 Oct 2024 17:04:41 -0700 Message-ID: <20241009000453.315652-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In Chapter 5, Interruptions, the group 3 exceptions lists "Data memory access rights trap" in priority order ahead of "Data memory protection ID trap". Swap these checks in hppa_get_physical_address. Reviewed-by: Helge Deller Signed-off-by: Richard Henderson --- target/hppa/mem_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index a386c80fa4..f027c494e2 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -267,6 +267,12 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, goto egress; } + if (unlikely(!(prot & type))) { + /* Not allowed -- Inst/Data Memory Access Rights Fault. */ + ret = (type & PAGE_EXEC) ? EXCP_IMP : EXCP_DMAR; + goto egress; + } + /* access_id == 0 means public page and no check is performed */ if (ent->access_id && MMU_IDX_TO_P(mmu_idx)) { int access_prot = (hppa_is_pa20(env) @@ -281,12 +287,6 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, prot &= access_prot; } - if (unlikely(!(prot & type))) { - /* Not allowed -- Inst/Data Memory Access Rights Fault. */ - ret = (type & PAGE_EXEC) ? EXCP_IMP : EXCP_DMAR; - goto egress; - } - /* * In priority order, check for conditions which raise faults. * Remove PROT bits that cover the condition we want to check, From patchwork Wed Oct 9 00:04:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827248 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 128F1383 for ; Wed, 9 Oct 2024 00:05:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432306; cv=none; b=c4giOcLsJE61EggyKPdnJWgPUYg+OxJocu1m3JNBNZGtxUZZvI1+AlKoyzt3PEK02arjqW9AO7GqpUR+n3lg0lo905fpyaKxyT018H5t7W36uEXVxxkw1vVL9A2cNP5IuolBIp4TxN1fRIITt5YTtquvAi3GnTqpAO7gQ+LsCuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432306; c=relaxed/simple; bh=42S/sQNxNr3KHey8FX2G1VylLlwoUMZwv9eJgyPPePU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e0ahcuiSsl5lsu/FpCEsQrb2ohIa/9qwiW+t5o3cui5ILhoWKhUjxOiCv6wUR9m4/W3lkl5DoeIkygnvT0q3/wWNUZHdpUQauOLdldhaODeHnlqMEJeR2dpKvcyussqMqcAv63HxSfSY71YR/8HjPwVIEF3clfrCRHR0zl7NK5s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=JaTY6OYF; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JaTY6OYF" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20c593d6b1cso10751435ad.0 for ; Tue, 08 Oct 2024 17:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432304; x=1729037104; darn=vger.kernel.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=8E2Z9ZSy95UZsg9Y2N2fIiaRxpU5aj12TR1V9ijHxjM=; b=JaTY6OYFfb7PZ2AxMDq1a7cVLsQ6BnT238/ZK8hnJLb6PO/Q/Gtewbx5I3AXNYGC8z 6A1b95f8/wGIeueE+Ht8YvfE0lVKbf4FQjs7d+RBlqLMMneVBSJ2N2PZ7gg/w8eMCL7d r7co9MdQg/FRLebj8j/FdMYsU4cFHePGd+qIHMV0TJoyQ+H8ut0GZxL0EXdmIVD3dtNC JjrIyQu4v/tsyaQY4C25jGNU4ObudWJBUiaprGAkX/U8XPkzAgQ+4B6iy8LghfSIlUbP wE3twyMHzjpJvUgA3wWrM1Qtv2WGfXwVQIY5jGKliQz9oZU+RsjzfseQhWijdtNgQDtx ouPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432304; x=1729037104; 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=8E2Z9ZSy95UZsg9Y2N2fIiaRxpU5aj12TR1V9ijHxjM=; b=eLQ+AqCTsNEtO8B2yPppP7oAJYLR6fZLR6cbdV6V+C1Axcq/BmprFAHI82yX0CZdIq Fy8y52K4U4chLPT9EfSEap+Z/APEUhTZyjl2jADtUWsZJNKs66LfbGVCulrloVNfxVn+ QWatXFVLFFatT6OZqCfz8fqMpyfTCXtkRAAZWROEGyteRGWWx2p9J6XeBfdIFGB6YRoM V0mYZR6saRPd0ZwmmrsEP4JV9ZOuH292RH5wzZWaz2+dpSO+g6zQWoVh6TWPELNTodbA Bvmwl0LFDTJ3RbD+kx6/CFbCrgiVFRO1zu0Ay/OlCHKxpejV/zVavHQsGHLzFRQ0fHo6 /d3Q== X-Forwarded-Encrypted: i=1; AJvYcCWsD+32osuJISYQnfrZBksIztMDtO19VkjQbt/8sp2Bt6GP6hNhkPmtBxXiQabkWJ4kqLhaaCtXIszOPn4=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1yGa8vyfezIhcOABDP84riTOtoLgaShvjDlOok9CtWQo8qkVB RtmXEEToOSdoEODYvLMXaZaYk7meUSeYkNW9vZ6xzkunJjw+5lteWTCP4Vw6Th4= X-Google-Smtp-Source: AGHT+IF0ZLww/QirXn6eqf2utM1nSiZwyzsJ3soHtkS1Z0DxnmXSBaV1UhTlgasVQznyDC1QSh7zOg== X-Received: by 2002:a17:902:dac7:b0:206:fd9d:b88d with SMTP id d9443c01a7336-20c637986d4mr11253965ad.61.1728432304454; Tue, 08 Oct 2024 17:05:04 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 09/20] target/hppa: Fix priority of T, D, and B page faults Date: Tue, 8 Oct 2024 17:04:42 -0700 Message-ID: <20241009000453.315652-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Drop the 'else' so that ret is overridden with the highest priority fault. Fixes: d8bc1381250 ("target/hppa: Implement PSW_X") Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/hppa/mem_helper.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index f027c494e2..f71cedd7a9 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -288,7 +288,7 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, } /* - * In priority order, check for conditions which raise faults. + * In reverse priority order, check for conditions which raise faults. * Remove PROT bits that cover the condition we want to check, * so that the resulting PROT will force a re-check of the * architectural TLB entry for the next access. @@ -299,13 +299,15 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, /* The T bit is set -- Page Reference Fault. */ ret = EXCP_PAGE_REF; } - } else if (!ent->d) { + } + if (unlikely(!ent->d)) { prot &= PAGE_READ | PAGE_EXEC; if (type & PAGE_WRITE) { /* The D bit is not set -- TLB Dirty Bit Fault. */ ret = EXCP_TLB_DIRTY; } - } else if (unlikely(ent->b)) { + } + if (unlikely(ent->b)) { prot &= PAGE_READ | PAGE_EXEC; if (type & PAGE_WRITE) { /* From patchwork Wed Oct 9 00:04:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827249 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA41B801 for ; Wed, 9 Oct 2024 00:05:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432307; cv=none; b=qWdIXzluQyCeMX7ELuRqr29bjsOsYxflxMp4RocSKYST6vZ0Ga+psHHKnOB9mmdiAbR+u6SlvMyqg4Oki3H2zsRHi10KCE5yINMvVyKoo28tJfXhk/SgqXmmjJXCL//fYk87iNJpS9PuCQ1dmVLHsoeVjVzGIQ/YQ6hU3L8FwDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432307; c=relaxed/simple; bh=uexbsWjvW+KtZKPv8kFelw8cpwu3yeLg90tgdbXR6+U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OnGue2tXEHpMnCDZrufsxEhFGIADH/DSK38/zyZCt37OziKk5+MpRVaXf6Hx/nzHIlrXB7/xruXFHkqPznFWarvLWpVCOhJ5WBXJ22avWspxfKEa09rD62FuZZJb6cE0ZM9XIAwyLa3lBXQEZU1354kWNscXur/TBKjfLSEagtc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=iyuP+NCi; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iyuP+NCi" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-207115e3056so57297175ad.2 for ; Tue, 08 Oct 2024 17:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432305; x=1729037105; darn=vger.kernel.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=xQhK8NjjgW/kNvx5X1m22TpA6VVxTZtyOqTVcWaZJho=; b=iyuP+NCiFqpNC02f0riekxEu+nCm7jg9xCXI1w2Zk6dMLNOAgb8OoR4WJ4fg3Y+a36 uWRKEmFnb7mKIC0NK7E95zRKaD0sThnZO6/fttcwzCQ5UhNGD3a9q6Zfo665U7nHTJVm OXEKsAocS980Cs+CaS4W0HLTiZyFSFE79D8ZWRqh969Aryq1+XxTaR+GUWRdTiFs6cN2 5pQrgb0gAkZczaTPH/2M4Qrr0GJX6sNMMgz15q0pugZ+FBfuAD+cN7rSVpodRGjXkplC AmguOcncHOFrdvGIepXwVMc1Fg+T0Gtr9+t10kdGxQnNSw8pRf3CULf64YlIS4P9koi3 x4gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432305; x=1729037105; 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=xQhK8NjjgW/kNvx5X1m22TpA6VVxTZtyOqTVcWaZJho=; b=SmmUKFGuV3J6MpU7R+IWP086ZRMfVhndWf86w1I0Rl0soQB7lcYec5VleZwy+Z6ClQ wEhOMHsmxBDedNEEdcZzVxOrYbnWgWZLqjdcOGJrn2kCIFw0FeopbdWI1nvdLdarWLBv FZrG/w0HJqwrq8yVO1WViI6I9wh7aj0doe4PuWdtm2+Kan09EFmRZ2g/Hs7qaFmRqFXo sM77QTUumJVKZ7Vjz+pHB1UlEnVQ2gpq1VlNcYRX0v7N8c0+FGmP9/rnJSlc6Z8ul/TF sg1YD3tKgvS3mOHR+KUJkNMUEORyrjEKP+vu+KGjsyGWMgsQ2qax0tZXqlVWB47sugE4 mAdA== X-Forwarded-Encrypted: i=1; AJvYcCXQgwcP/cq6oSkezK9XIi2SZJqnOsiioOA0B5E7asblLzfe0krGEAwnG2hI9tUgxe10KNYWDhmOfeL4CYU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx68w9T1GPJACHM5BeP8gFYknupZhmpDLDcU+F1zYYstuK2GaZg TQlbjuIU5p4N2tKcRaIU3xuXWfhC2dt9ajcs/NrqoLZ8zUV1gmqwJXhgaqJ48JI= X-Google-Smtp-Source: AGHT+IGk0V3WqNWZpuoKiyjHCbvkavwK7mPvzoRJ0f7iYAkKJh77UVywliO2AjnwG+Rua0FM3sG5Mg== X-Received: by 2002:a17:903:2309:b0:20b:51c2:d789 with SMTP id d9443c01a7336-20c63711761mr12234395ad.16.1728432305301; Tue, 08 Oct 2024 17:05:05 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller Subject: [PATCH v3 10/20] target/hppa: Handle alignment faults in hppa_get_physical_address Date: Tue, 8 Oct 2024 17:04:43 -0700 Message-ID: <20241009000453.315652-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In Chapter 5, Interruptions, the group 3 exceptions lists "Unaligned data reference trap" has higher priority than "Data memory break trap". Reviewed-by: Helge Deller Signed-off-by: Richard Henderson --- target/hppa/mem_helper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index f71cedd7a9..d38054da8a 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -221,7 +221,7 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, g_assert_not_reached(); } prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; - goto egress; + goto egress_align; } /* Find a valid tlb entry that matches the virtual address. */ @@ -323,6 +323,11 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, } } + egress_align: + if (addr & ((1u << memop_alignment_bits(mop)) - 1)) { + ret = EXCP_UNALIGN; + } + egress: *pphys = phys; *pprot = prot; From patchwork Wed Oct 9 00:04:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827250 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8583370 for ; Wed, 9 Oct 2024 00:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432308; cv=none; b=GIXgCJIZX7MHcQoNMuUO6++2f2LdA6uF6KoiiI0H7dpKx1m8aquO/tDYeWHDgdGV97abdqKyX0JZ8k/LeRTzJw12sHJ6HNJtEX5G39GrfnkuR64/KeMB+pOYRDA48/OJWHiexJKjRFYcccw9dNsWYSAkJpeMMgNzEfAgTXfMCfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432308; c=relaxed/simple; bh=XNSUPs2wawHWMkJmFOseTF/e5uRuHZbQc3DlNbkB4Vw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PekN2TzUf+8XDPQPeValcVh7ZXNl+6IDCQXaBGJ4lbdV8b+I65xEkgq7XgVg3EheH6rMyGuJGn5WWZNwtyZrMtajeer2NtBYuPjzXingnt7kjFN0WjrxPpo5yeFEgVDlE5BEXoppbadSRpunZTod/4wO7vllyMSarzl/1F1haSw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Ov1Hd0GR; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ov1Hd0GR" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20c544d34bcso12092875ad.1 for ; Tue, 08 Oct 2024 17:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432306; x=1729037106; darn=vger.kernel.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=iV2KSUuCTdEDpKpG+VIBV8pupsJQOA9ecDi8J+rVd34=; b=Ov1Hd0GR5dciY3n5CcPQ7NZiZZwGDMEd5+UZD4RJwZe74VBRlcJnXpa9aPP3CmZibZ vCb9lbKF+Yn7OtFVkRCS2puuR12bM41/8TzitrcqTyg7N0mFtw2A9L2foJEuTfTdWKbT Tg4sQXRrgIWSdfmLO9qvOn/h4Y0PJVZaBcvG3a0BewS/ifO1po7Q/cpqtmrBm1LBLUPA 8waYJ39OFqOZLPhBODS7bqztFJncNGx9MGsdguLs4hsoCuRQYNHIL/l1Klbz6+KuTWXN yQvrV1pMsgP87VUPkk23Gz5NsF4MxWWtGEv00tPIRmfAnNP0QoPExSSytTYFeaNv0MSc Jheg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432306; x=1729037106; 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=iV2KSUuCTdEDpKpG+VIBV8pupsJQOA9ecDi8J+rVd34=; b=GPf+i+gJTjFRUVVbd1ZaNf2C1Wrj9S8uxWxGi6eUbIiqLogCnfUmFZ8ZIgcyaNRrAU g0PEJatFxtyWJc5mdKunvSaSrZBrUh+8u4tuJkgeifN+VyAi6m/+iYS8owyFQ+N/Cd4c /fLFxOXig57cLMQkKlOkTLrVL2xpTWpLSiOdlBDiR/Ju2sqGkwfMEGBge65MMoWi6mXc aiII+THGs+c8Jb7pUm70hY4evZbCD8kWl3LrKoYdlPvssZp9qxFtvc5wOFlSCmTgxdDd gKSchr6XzNRMylzP57Tg0AuYK/Hrb4uOHVHH4oFbfVOMiz9ZtkJKnUdGu3cC2PVMxhvq vOFw== X-Forwarded-Encrypted: i=1; AJvYcCWWSQqgLy8LVUX9eCH8UwD2G3dpgKd+RSehlbOVM85JNIewl9nHSM8BHbuUHJCjxJJIoh6v/8P6HOIlw3M=@vger.kernel.org X-Gm-Message-State: AOJu0YwR6V7NLYESWnLxsISGFL8QP5Kwh5HGNqdHfdogyhgkst1aSdP4 lBHa1Nif2gZZnjO29NgAEFqkg68+7cDyrWOkAgMeoiz0vcAJfxRoJI0Ws0e4svw= X-Google-Smtp-Source: AGHT+IEKU+69FGHaarUOvElg72DCHkm1xPG7wfOM2NLThus+mTJDQJLk8D0LtS7DglEQU4MbeYyvAA== X-Received: by 2002:a17:903:110c:b0:20c:5698:75cd with SMTP id d9443c01a7336-20c636eb2a7mr13032315ad.2.1728432306088; Tue, 08 Oct 2024 17:05:06 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH v3 11/20] target/hppa: Implement TCGCPUOps.tlb_fill_align Date: Tue, 8 Oct 2024 17:04:44 -0700 Message-ID: <20241009000453.315652-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert hppa_cpu_tlb_fill to hppa_cpu_tlb_fill_align so that we can recognize alignment exceptions in the correct priority order. Resolves: https://bugzilla.kernel.org/show_bug.cgi?id=219339 Signed-off-by: Richard Henderson Reviewed-by: Helge Deller Tested-by: Helge Deller --- target/hppa/cpu.h | 6 +++--- target/hppa/cpu.c | 2 +- target/hppa/mem_helper.c | 21 ++++++++++++--------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 526855f982..e45ba50a59 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -363,9 +363,9 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, int); void hppa_ptlbe(CPUHPPAState *env); hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr); void hppa_set_ior_and_isr(CPUHPPAState *env, vaddr addr, bool mmu_disabled); -bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); +bool hppa_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr addr, + MMUAccessType access_type, int mmu_idx, + MemOp memop, int size, bool probe, uintptr_t ra); void hppa_cpu_do_interrupt(CPUState *cpu); bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req); int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 7cf2e2f266..c38439c180 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -226,7 +226,7 @@ static const TCGCPUOps hppa_tcg_ops = { .restore_state_to_opc = hppa_restore_state_to_opc, #ifndef CONFIG_USER_ONLY - .tlb_fill = hppa_cpu_tlb_fill, + .tlb_fill_align = hppa_cpu_tlb_fill_align, .cpu_exec_interrupt = hppa_cpu_exec_interrupt, .cpu_exec_halt = hppa_cpu_has_work, .do_interrupt = hppa_cpu_do_interrupt, diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index d38054da8a..b8c3e55170 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -424,12 +424,11 @@ void hppa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, } } -bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, - MMUAccessType type, int mmu_idx, - bool probe, uintptr_t retaddr) +bool hppa_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr addr, + MMUAccessType type, int mmu_idx, + MemOp memop, int size, bool probe, uintptr_t ra) { - HPPACPU *cpu = HPPA_CPU(cs); - CPUHPPAState *env = &cpu->env; + CPUHPPAState *env = cpu_env(cs); int prot, excp, a_prot; hwaddr phys; @@ -445,7 +444,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, break; } - excp = hppa_get_physical_address(env, addr, mmu_idx, a_prot, 0, + excp = hppa_get_physical_address(env, addr, mmu_idx, a_prot, memop, &phys, &prot); if (unlikely(excp >= 0)) { if (probe) { @@ -454,7 +453,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, trace_hppa_tlb_fill_excp(env, addr, size, type, mmu_idx); /* Failure. Raise the indicated exception. */ - raise_exception_with_ior(env, excp, retaddr, addr, + raise_exception_with_ior(env, excp, ra, addr, MMU_IDX_MMU_DISABLED(mmu_idx)); } @@ -468,8 +467,12 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, * the large page protection mask. We do not require this, * because we record the large page here in the hppa tlb. */ - tlb_set_page(cs, addr & TARGET_PAGE_MASK, phys & TARGET_PAGE_MASK, - prot, mmu_idx, TARGET_PAGE_SIZE); + memset(out, 0, sizeof(*out)); + out->phys_addr = phys; + out->prot = prot; + out->attrs = MEMTXATTRS_UNSPECIFIED; + out->lg_page_size = TARGET_PAGE_BITS; + return true; } From patchwork Wed Oct 9 00:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827251 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C28C0383 for ; Wed, 9 Oct 2024 00:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432309; cv=none; b=Bdjf3oaCwADnK09ExguQ0P41ToFmJbA8tLcQ/2fH3Sz2mp4buXpYP1FnOnWf8c1fmZM5WWfLIR0rR0o86uRXdiULNiO1is0EFGUF5VGlguDgWLN5ghzdx/fARXmCIVgkht0S085heUrI7YOwDIe+1r1BrDuzuHq+XUkVfV2eQ/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432309; c=relaxed/simple; bh=FzDI4v0VT9EkG9GKZr83dPch/xwgRQbjlipFQebC3gc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ja6MDSwkElkSDlBdealysEmvmJ2DaPAZpBfy9Ho3heje7+fkOyoaM3sUKehNbEiTJzBUNethBEjs8a17yb1fMGN7zy/BqmeX5ACewlOsIBTSG9cdZ/H7yTbJkDSJmjVkGJA/mexcs2GBbInsfQpB9BMg8NP3UoRJxrW76eNuN6s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SUVN2drM; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SUVN2drM" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-20b95359440so53727325ad.0 for ; Tue, 08 Oct 2024 17:05:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432307; x=1729037107; darn=vger.kernel.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=RUID/VOY3Ga2ZN/DeZx4JrZs9/xknXUyzF7dZ/9YQNo=; b=SUVN2drM7+g7mATbOOr7JozFbyVQXC4lBf4m1g8eykebsSXA9g2Fj70+HzNTc2f3zB /3cRXwcnaOxrE4ui2gfT9Rf6FPsyNIHPjdy0OsdDX0eTnG4oDhq4yISJKinfYIGQWIuv KalJNb9N/O6XWBFpg+yNl0g2s6eMFDBQQ0OoRUzjljK3WQm/R2o4VzpJffhZ1DAa09Ut fp3sIH0HNvectIEthMwh2cBNd3JGK5UruqPyhAUI7O4JqvQD03Q/yrc1bQJW7bIllTFR unn+agWWTVLjR6zDZZxlMwvbducPBQq9ZfLKWUVrkSkfUVXps1AMxrIZtAwCBR8y7MBF uVzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432307; x=1729037107; 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=RUID/VOY3Ga2ZN/DeZx4JrZs9/xknXUyzF7dZ/9YQNo=; b=Kmb36/+QDtqGooLsToCaR6YyaWkAkYWxxowl9qw/o8RPQKX+CRmWklccgZzV5OjmC9 5VQxtYCP65RaTX71jBD17SAIkY6nUyzeijuQduhH85NSOk0NjLNa6xs6zAzdzA23p5yx hOU9XYPOhgIiIAsmrFeCQqaZ0yLaM7ZarJgvnH0Z4ACUb/oaUKDS6vchT+QKMMAO+jLz XUNby+C8674M8+X/a+7+f232fF9lt98LQOc3nFvaV4sxVJ7iAfeEcoqXGUa8xWim/Y9q PXuFP3uV5YF0SBDHu7GBB0KsHbSV1hzLpTYVObM5H7HljH1gUSZXi2DdYOv9b1Aiv/Cm cNUA== X-Forwarded-Encrypted: i=1; AJvYcCUT5IvylqytyNeo/JQo1hTj18nwllcIJ+exsWeMHQzMdAxvjbemKeCnb8uQ6Y3MlJiWIuwqafBOMSus8o4=@vger.kernel.org X-Gm-Message-State: AOJu0YwICBYYwk4a/gR2yNQRDLXVWqJ6bCZjsPbTQmVGoCMcdNvFrUci HB6wi0Iqp606eWsI+wDNM3MzZwHAtSSllBoVTzJ8/AL3JTbjhhhCstnMNgX3Mic= X-Google-Smtp-Source: AGHT+IEOzR02cuGQIAfO5rhioXqq6+S1yUdY62tdcjtmeVq0WQ3OZwwN00IC+X3KAkSW8TC6DwnsKg== X-Received: by 2002:a17:902:e88f:b0:207:2093:99bb with SMTP id d9443c01a7336-20c63743a92mr10917825ad.31.1728432307098; Tue, 08 Oct 2024 17:05:07 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 12/20] target/arm: Pass MemOp to get_phys_addr Date: Tue, 8 Oct 2024 17:04:45 -0700 Message-ID: <20241009000453.315652-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Zero is the safe do-nothing value for callers to use. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/arm/internals.h | 3 ++- target/arm/ptw.c | 2 +- target/arm/tcg/m_helper.c | 8 ++++---- target/arm/tcg/tlb_helper.c | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 1e5da81ce9..2b16579fa5 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1432,6 +1432,7 @@ typedef struct GetPhysAddrResult { * @env: CPUARMState * @address: virtual address to get physical address for * @access_type: 0 for read, 1 for write, 2 for execute + * @memop: memory operation feeding this access, or 0 for none * @mmu_idx: MMU index indicating required translation regime * @result: set on translation success. * @fi: set to fault info if the translation fails @@ -1450,7 +1451,7 @@ typedef struct GetPhysAddrResult { * value. */ bool get_phys_addr(CPUARMState *env, vaddr address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, MemOp memop, ARMMMUIdx mmu_idx, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) __attribute__((nonnull)); diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 659855133c..373095a339 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3572,7 +3572,7 @@ bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address, } bool get_phys_addr(CPUARMState *env, vaddr address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, MemOp memop, ARMMMUIdx mmu_idx, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { S1Translate ptw = { diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index 23d7f73035..f7354f3c6e 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -222,7 +222,7 @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, int exc; bool exc_secure; - if (get_phys_addr(env, addr, MMU_DATA_STORE, mmu_idx, &res, &fi)) { + if (get_phys_addr(env, addr, MMU_DATA_STORE, 0, mmu_idx, &res, &fi)) { /* MPU/SAU lookup failed */ if (fi.type == ARMFault_QEMU_SFault) { if (mode == STACK_LAZYFP) { @@ -311,7 +311,7 @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr, bool exc_secure; uint32_t value; - if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi)) { + if (get_phys_addr(env, addr, MMU_DATA_LOAD, 0, mmu_idx, &res, &fi)) { /* MPU/SAU lookup failed */ if (fi.type == ARMFault_QEMU_SFault) { qemu_log_mask(CPU_LOG_INT, @@ -2009,7 +2009,7 @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, bool secure, "...really SecureFault with SFSR.INVEP\n"); return false; } - if (get_phys_addr(env, addr, MMU_INST_FETCH, mmu_idx, &res, &fi)) { + if (get_phys_addr(env, addr, MMU_INST_FETCH, 0, mmu_idx, &res, &fi)) { /* the MPU lookup failed */ env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK; armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM, env->v7m.secure); @@ -2045,7 +2045,7 @@ static bool v7m_read_sg_stack_word(ARMCPU *cpu, ARMMMUIdx mmu_idx, ARMMMUFaultInfo fi = {}; uint32_t value; - if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi)) { + if (get_phys_addr(env, addr, MMU_DATA_LOAD, 0, mmu_idx, &res, &fi)) { /* MPU/SAU lookup failed */ if (fi.type == ARMFault_QEMU_SFault) { qemu_log_mask(CPU_LOG_INT, diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c index 885bf4ec14..1d8b7bcaa2 100644 --- a/target/arm/tcg/tlb_helper.c +++ b/target/arm/tcg/tlb_helper.c @@ -344,7 +344,7 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, * return false. Otherwise populate fsr with ARM DFSR/IFSR fault * register format, and signal the fault. */ - ret = get_phys_addr(&cpu->env, address, access_type, + ret = get_phys_addr(&cpu->env, address, access_type, 0, core_to_arm_mmu_idx(&cpu->env, mmu_idx), &res, fi); if (likely(!ret)) { From patchwork Wed Oct 9 00:04:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827252 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7443801 for ; Wed, 9 Oct 2024 00:05:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432310; cv=none; b=PtUTSkQnEp7iEV+6SEHSAzfp1ng0h3Jlv7iv1E58BBZ9phlNzBgkpc14N8sRHnVnZE+cwmw+fvqeyzCykvpGDxfkbQ5IMfc/HnfcrjTU41uR+7d+u0XapNBUQx6yE140D5JrBRk4i2kyYRPyNO1wONhZp65E9502RYHruAX527w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432310; c=relaxed/simple; bh=+rLsRRRnQcg9xk+UQX6OcHHIiYgacT7e4SiSslh4Klk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=etpmLXSinTDzag1PR9fBk/0wI1NE3RKW7Lw91JhFGEbOdMWF1LJ8Zj2Sdni9uqbiYEv9lQAWA8xm7f0smZe2dpWuGTIE4W2x0Q9pt8Sshzf6M3UKKp8yZ2f6GBdIUPeVqP/8SNeaxYgQIUcn/ctHK0HO4c6FjifSXzKxeH6GtkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=K8mhFY2v; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="K8mhFY2v" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-207115e3056so57297425ad.2 for ; Tue, 08 Oct 2024 17:05:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432308; x=1729037108; darn=vger.kernel.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=I928rOfU7rFS4/uAexBKDkmn1Lv4VMSl/VKyNRV9wmg=; b=K8mhFY2v0ZgDacNpSjgSntfeT4II4WXhLoaNf3rv7DD6oIg1x4jAq1T+u28uuvvYTj mYGHsR10Km6TSrN12m3fD1ZyiQkuBgZ1LbWjdKQuiJdigEYhMLIHqMsDa9WJ6OKP9inB AVsiE9l98xmThvejdN77wsYmjV+UoFm5TbtHEAlHGgeeEMgEDRILUtRbMuIpH8yxNhH1 DK/vKmTbP7jp6iv50aeBpDjgEnsIbgJIGxgVKkPTDDeaxCOqk2XiHY3shf8MF4DxAORe ETGqMJNA5piKi7f0tv9DU9NeYvrnyr5mifBb7YdJi7Q78rGc39XqXrWcx+G8YkyYJdw5 LY0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432308; x=1729037108; 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=I928rOfU7rFS4/uAexBKDkmn1Lv4VMSl/VKyNRV9wmg=; b=c1kTU9q2vldq9goPG/1FRu48Oi1k+uisANkBOaBhBwLcIeCCTSPt56+UKRY67FQJ4b JzHtQZ6hJOfdHS+KfBWZvxQPjkf2llYNXIoDdMWj5xbGanx9NysQMvT7K5k1rY/4IB+C Snto0llBc441Tqy2BjXGLN5m097g7ZgzxKgOvAZlDE0Nm7nsAHWQ/bpylrT9EzFtcUA5 kKhyFOPgq9Dpn0y9EhfXettXHsfR741Weei4iaMdvt3ywJ+dgFqGXSw5PxT3poSzwTy7 weoXo4i3pOUrBPhQN2wyiSVS+ppZmdXtGUpxx56OGwdy5llKYpsf41QAuhos0os3HAgF 2v9w== X-Forwarded-Encrypted: i=1; AJvYcCW2mJanKcbDFmg46kTBBhHtWAh1FRNnFk2P/dZUZjOMeDpyEd+uttm9UqY0G8FNXkZ1e7OI4Yo0cs4VE5A=@vger.kernel.org X-Gm-Message-State: AOJu0YydrXDhQhmMVb8wRRIcmIHKwm33nO9I+V61rotwj/pMCx0YtZuc 8PyMxwGwouxsrZkKeQNmTMB+5y9uUfIjbVbIiePktBxvl75J1PN978zhkA1zGzE= X-Google-Smtp-Source: AGHT+IFMRMcxUNXCHul99WM0nOEYQH8Nd6y4x6kBohzqFF7CIBlmB9qDX2IdxPxzJUxR3zV7HkR2Wg== X-Received: by 2002:a17:902:da8d:b0:20b:7be8:8ecf with SMTP id d9443c01a7336-20c6379030emr10548965ad.53.1728432307943; Tue, 08 Oct 2024 17:05:07 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 13/20] target/arm: Pass MemOp to get_phys_addr_with_space_nogpc Date: Tue, 8 Oct 2024 17:04:46 -0700 Message-ID: <20241009000453.315652-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Zero is the safe do-nothing value for callers to use. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/internals.h | 3 ++- target/arm/helper.c | 9 +++++---- target/arm/ptw.c | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 2b16579fa5..a6088d551c 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1461,6 +1461,7 @@ bool get_phys_addr(CPUARMState *env, vaddr address, * @env: CPUARMState * @address: virtual address to get physical address for * @access_type: 0 for read, 1 for write, 2 for execute + * @memop: memory operation feeding this access, or 0 for none * @mmu_idx: MMU index indicating required translation regime * @space: security space for the access * @result: set on translation success. @@ -1470,7 +1471,7 @@ bool get_phys_addr(CPUARMState *env, vaddr address, * a Granule Protection Check on the resulting address. */ bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, ARMMMUIdx mmu_idx, ARMSecuritySpace space, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) diff --git a/target/arm/helper.c b/target/arm/helper.c index 3f77b40734..0a731a38e8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3599,11 +3599,12 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, GetPhysAddrResult res = {}; /* - * I_MXTJT: Granule protection checks are not performed on the final address - * of a successful translation. + * I_MXTJT: Granule protection checks are not performed on the final + * address of a successful translation. This is a translation not a + * memory reference, so "memop = none = 0". */ - ret = get_phys_addr_with_space_nogpc(env, value, access_type, mmu_idx, ss, - &res, &fi); + ret = get_phys_addr_with_space_nogpc(env, value, access_type, 0, + mmu_idx, ss, &res, &fi); /* * ATS operations only do S1 or S1+S2 translations, so we never diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 373095a339..9af86da597 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3559,7 +3559,7 @@ static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw, } bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, ARMMMUIdx mmu_idx, ARMSecuritySpace space, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) From patchwork Wed Oct 9 00:04:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827253 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ECE036D for ; Wed, 9 Oct 2024 00:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432310; cv=none; b=O8j9HyrQXFPc5hiwlPijFfgevPmYNylB9OdetH4Dxdsfx/aCQIScyZr+p728TNmfYN1hrjuDqyo9MGmfG/nUsmydcNjA99nvnB5IkhTP/JFtOdIv1ASN/L2wDw7s/YfWnieVxcdB/maM8IkQlMi1ozFCn/qTfxGYFi4bGSh2w00= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432310; c=relaxed/simple; bh=X7/HRCKcBNpTWFYJXvWLm9o6rN4jurUTp8ma9vDBW88=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ODbVgUBTRUPp0dj02sz/UIvOHt5CkCXXiNaoMvU/GxqpxYdhLT8T3A2Ci329zW9q9ZeETkz22F1ufDBm2e5lUWk9uZWLNCclNEuBp5ZQl8pk+yAzbkXMy07aqXr2+DEwSHgRhvJ5pe2IfNgo72ouedH6Ky5iv9fq7uIjkULt8wo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=GHpbOXYL; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GHpbOXYL" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20b49ee353cso58170555ad.2 for ; Tue, 08 Oct 2024 17:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432309; x=1729037109; darn=vger.kernel.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=617h4byv7OP/ct3y2kJCr5k6Qy1wZsttJUBcCYmwvNQ=; b=GHpbOXYLH78s6+QpQ7Xdx2vUhbs3gjUHyo8xMu+uCa6icEyHBbFTYrowwRUXSOtkbt MFnvRMmiqZILIJfzOk4ySQ1HkwBx+PBcpNKYTmMhx4d9Z4ajO5vxXOFV4xfsPuWe64Fk 0Bz9NsFiSOFPNkVz3LLd8R6ooHu2hCrnsORj1HcIQ14dYqeLBEjT7zse+jME2YEN1Pcz 7mQIrUIVrwfMf0HY/c6IJsX50S3G01cco3UfEq/EW4G0r1h0jX5o89nV9YlPzx1/vWKz joRUsmJxegQfg59f9eZJ4HcB+aLYXov2FggraNNCg5TvFhCconFvnOGBqcK7GEYmb+RM akbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432309; x=1729037109; 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=617h4byv7OP/ct3y2kJCr5k6Qy1wZsttJUBcCYmwvNQ=; b=PgvTaZa+B8GsdjnUisqH7gJ5mGuNHw8qF3cHQA8fffIa0+C5SZfk94w7DmcW2Wlna/ hVJRvf8srn3nHzUoMrLm0dkv/AtbpeKUoJ1BxNOK7BJ4Wp8mgJGLLYojoNvvzKkiVd4h Pu4Os8dFC5SRXRlB1Hd3wci4T9kpe5IENubouDlXc4mJ9cVI/3XCcCVuL4DhOXdp40Vd LpRrEhhuduwMR/kJGKTjisA1aPM/QmDI8XlkPQstSj37naAlrRAh5iR/jcuWSRDYkaiV 9hBq8aYmnmPCVlWlJ5gpzsBTI/9olWL/4IydUSRmOr2c95MmAmsBk7Uc/zKQFPOQmzAL Yjrw== X-Forwarded-Encrypted: i=1; AJvYcCX39CioNAD9VDfipdaIHFxIfXgpnDl+MMr1n0pHR2FXK8Pg8E6OR2oSAcD9Wek56w+JZw8Lohtw4NFPzq0=@vger.kernel.org X-Gm-Message-State: AOJu0Yzuq9BZE1UEVPsSlutrGdFoWSl/Mt/4k3wQU2HoorE8NkJE/z3k /m1ILSLr1buSj1/Ps3Hcx2WoH62p8E81WoSaYJAeukk6tyDrwp5EwQbAxYf1Ku8/EfMnsRH8AdO r X-Google-Smtp-Source: AGHT+IGz831u80Gw701tK56DvhnXhyXPWJ4bmGeVXTKsGYyVIeaQp323LRx3BoQmx+OjkzUmoyjqwg== X-Received: by 2002:a17:902:e543:b0:20b:5be:a403 with SMTP id d9443c01a7336-20c636f5d9fmr11781085ad.11.1728432308873; Tue, 08 Oct 2024 17:05:08 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 14/20] target/arm: Pass MemOp to get_phys_addr_gpc Date: Tue, 8 Oct 2024 17:04:47 -0700 Message-ID: <20241009000453.315652-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Zero is the safe do-nothing value for callers to use. Pass the value through from get_phys_addr. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 9af86da597..e92537d8f2 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -81,7 +81,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi); @@ -579,7 +579,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, }; GetPhysAddrResult s2 = { }; - if (get_phys_addr_gpc(env, &s2ptw, addr, MMU_DATA_LOAD, &s2, fi)) { + if (get_phys_addr_gpc(env, &s2ptw, addr, MMU_DATA_LOAD, 0, &s2, fi)) { goto fail; } @@ -3543,7 +3543,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { @@ -3641,7 +3641,8 @@ bool get_phys_addr(CPUARMState *env, vaddr address, } ptw.in_space = ss; - return get_phys_addr_gpc(env, &ptw, address, access_type, result, fi); + return get_phys_addr_gpc(env, &ptw, address, access_type, + memop, result, fi); } hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, @@ -3660,7 +3661,7 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, ARMMMUFaultInfo fi = {}; bool ret; - ret = get_phys_addr_gpc(env, &ptw, addr, MMU_DATA_LOAD, &res, &fi); + ret = get_phys_addr_gpc(env, &ptw, addr, MMU_DATA_LOAD, 0, &res, &fi); *attrs = res.f.attrs; if (ret) { From patchwork Wed Oct 9 00:04:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827254 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C292383 for ; Wed, 9 Oct 2024 00:05:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432311; cv=none; b=HextikiT8KKKihL+wi/PnqhTKXuXzTpSSfwLcLeO6KNKMxLAMNqrX46oFdVhMjP7z7mP6Sgxuu+OMnl5UVt3SPrgFTxX/8u6KClY0vGKr3Z2+dS4+1cPdEJxjXW883xKFnXlJ/mC0WFVxxigmEfLTuEyQZFWqJtMIvreo62rRvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432311; c=relaxed/simple; bh=BDp0O6JIpdOVZn6P5SuJhCZ2UsEmiTjyaLAP2jh38CA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kmcNenotZ78ZsKub99dMvfeKT3z0VE3nNjFOOVkdsRrt+oyWCSH7lFzjVxvUhYKkaLe142ushyf92VDwnrxA3q1njqhuzjw1M/9YhowaPyg2GPY2PzcWWWpkerbtAumy6qomTGrzwfuW2FUHFWeem2+1D+9gZi4XlvRjvJODUWU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=azH7iXO9; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="azH7iXO9" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20b0b2528d8so70928855ad.2 for ; Tue, 08 Oct 2024 17:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432310; x=1729037110; darn=vger.kernel.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=HpCts7Lc7po90jMJZMaWUdEUzHFwVBTsaL90Hh3zO7Y=; b=azH7iXO9pfr/LoPHYgbcUXHoLd84hJVBV3nv/gGi3xcUBWAXbCnz7764ROVX/yhi9h qam1F641S9NAy/8Js15jGzBJxrRZqfkbVNmYs373UndLgb03M8UI3YhzCjgpbfzMNDN+ hsysgIDN2jtrF1X+pqYzIDS0VFmiGd2hDbd8ItL2VX8ZzVvmcMjqoowhCsR4HNckXfUR KgH0BxEE7HvUEbBCvB9xVJ7EL5ynFKIcTIw4VoCnkwbvqeaB886xrhAhgYnRFtPgxox7 0cqMl0enLkX4TPCxzZ0LG4m8HEqp3Xp+cPupQA/+9D6C1deyGO0ZoGpLcCjL+c6c5o4c jLJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432310; x=1729037110; 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=HpCts7Lc7po90jMJZMaWUdEUzHFwVBTsaL90Hh3zO7Y=; b=dNzD7iaIxS6B7Qs9kEYq9Loui5z2VwwTA2ULhbl+7/ZqYoWZ6M90QDb8vdGEXin8Yd 1CxCvWskoYwuTQ7U852N6fiLQf9XB4Kns3IvAQ0plP7LL5zsYdbORSrCS5RYD0eJP4k1 DDDNXw0jN3FsIZsyqeWcE/npav+04h/xkNX5wB3drGlytSPL/t6vLMyJwPatTFbKN4oJ EokU3KH2l/r40OuPf2o7u5uBVCFvy9ggZk6XXHLkuXw1ZscUqCbCtqq/8GNFAwlc7Aa0 dI41TKNcSMAxI6/ecGHw15/DoeJRcZ8+lb5re907mvPEJK+JS85W1n9g/h8Ha2Nm+mcO TtQw== X-Forwarded-Encrypted: i=1; AJvYcCUMKEw4o2m5Niv7eqALKQ496PQHX9ScAo+MiRGQ+RjFepLKChhwZHpAcqb37MrnXTmt0Yc4zTtTxZkZb20=@vger.kernel.org X-Gm-Message-State: AOJu0Yzn8fIvLV/09S/7x/UwQYjbN/eK6Mm+9s5CyqiV2R9uaoe1iG1n kubEDwll+JHqO3i3FK2rt4MR/H9/DrGVQlYwydyuvugKNYFDdGEipDcpo/LtLOk= X-Google-Smtp-Source: AGHT+IECyy3ECPwpIxrRErzht1GulXjMyxKnwSvtoRqfwlCQOZkW3JggsvRngQz//es+//aYqmgOdg== X-Received: by 2002:a17:903:22c9:b0:20c:5960:bd35 with SMTP id d9443c01a7336-20c63710345mr8780115ad.20.1728432309687; Tue, 08 Oct 2024 17:05:09 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 15/20] target/arm: Pass MemOp to get_phys_addr_nogpc Date: Tue, 8 Oct 2024 17:04:48 -0700 Message-ID: <20241009000453.315652-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Zero is the safe do-nothing value for callers to use. Pass the value through from get_phys_addr_gpc and get_phys_addr_with_space_nogpc. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index e92537d8f2..0445c3ccf3 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -75,7 +75,7 @@ typedef struct S1Translate { static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi); @@ -3313,7 +3313,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, ARMSecuritySpace ipa_space; uint64_t hcr; - ret = get_phys_addr_nogpc(env, ptw, address, access_type, result, fi); + ret = get_phys_addr_nogpc(env, ptw, address, access_type, 0, result, fi); /* If S1 fails, return early. */ if (ret) { @@ -3339,7 +3339,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, cacheattrs1 = result->cacheattrs; memset(result, 0, sizeof(*result)); - ret = get_phys_addr_nogpc(env, ptw, ipa, access_type, result, fi); + ret = get_phys_addr_nogpc(env, ptw, ipa, access_type, 0, result, fi); fi->s2addr = ipa; /* Combine the S1 and S2 perms. */ @@ -3406,7 +3406,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { @@ -3547,7 +3547,8 @@ static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { - if (get_phys_addr_nogpc(env, ptw, address, access_type, result, fi)) { + if (get_phys_addr_nogpc(env, ptw, address, access_type, + memop, result, fi)) { return true; } if (!granule_protection_check(env, result->f.phys_addr, @@ -3568,7 +3569,8 @@ bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address, .in_mmu_idx = mmu_idx, .in_space = space, }; - return get_phys_addr_nogpc(env, &ptw, address, access_type, result, fi); + return get_phys_addr_nogpc(env, &ptw, address, access_type, + memop, result, fi); } bool get_phys_addr(CPUARMState *env, vaddr address, From patchwork Wed Oct 9 00:04:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827255 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78612801 for ; Wed, 9 Oct 2024 00:05:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432312; cv=none; b=NPcQZhcr8r7sAuc3B+12Jl8BihC3CXwF1fH9FIb3Tz5LT3E9NDLiX/eM5DMwKKcKYZTh4C+5RhAOROd6q59covy7RtE3YiTkwDw3fpBWKsRu127GXJTxUAl0q211rUCiWJyr2fRnL9Vb51+FqXis6uJfmH1ULHe0fq6SLCDRGiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432312; c=relaxed/simple; bh=pDgf/rzqRVogjXyED2cVC5XS7hpf4sX5D/dwk1pCY1M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ttijkRIvH22bHgNK771+W2a+NabWc7JYrSe82XFkJ2HVg9LMh1oMqob3tAgAoMb2WJtnQ6ucwcVl/YzyYTaw12ne1IWyJTHLWjudFgjlcRZSQxorq/kheCaKZ7UL5Wglmr/rTpBarSsMGEK4LPBsO94+OGry2gEhMQm+pSHh/pI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OHISx6xc; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OHISx6xc" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20b7a4336easo45876045ad.3 for ; Tue, 08 Oct 2024 17:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432311; x=1729037111; darn=vger.kernel.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=nPsGlRApUHllpr7HECmYu85LwKI3gq1PeB/gQzKhtMY=; b=OHISx6xcztpG7qp5aHVjNAF/rIiBeKQmcJyNgkFCymzZB2FKJ1RhSZfdq1wLNq0yS3 htrCC+iembtrXWMU0wHeZxwgJ+/6A9B9I78rUgBgV5abnJW1YxwpGbvoQw8KnE22UkxI L3Kkgnug59kiIwo+Ckf7ccn7r6onctDqPXZOPcnw4vQDubkqxeekLGp9bWKWkE3Atvtf naLtESUF/J6jCNKZmEEhBtpxPreMzJknq1WEec/bI9uweQ6td6s8i+eRbMpmJqDMjd1W b2x3HInIfEkb8IwrERBn7z2c+UyGvP9VXfsqsECZ7/tIrVgKfCLJbbpQS9KOhb96NuhV +rdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432311; x=1729037111; 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=nPsGlRApUHllpr7HECmYu85LwKI3gq1PeB/gQzKhtMY=; b=WB3ejevy+yfnBIgCir+a8gQe5pKjdCbFK2y0xkWxt57X6nFw8h35aPS1zdZb6eYliu fxPh+FW2cUSNZXOmp39YavwCysng0gDtqJx0uyMCHC9BORpV6GxG8KPJmajKFT/iAHBH L4QsBt7FjKqUhu2hpAeqTT2B4E9gCtWDIoI2zV7VehZus7lq0Ke/QxfrHmP3KK49Tixm /V7GagYmfB8cutrIHv0Ilv0S7hwG0cjlju/NAAiFSDNrlTh8uvvbhyLd5/cnhuwzIwry Wal1B7BQr+0Gj8aDf8uwDRtr8143QjNKEhXjjRHonqpprE/jMDGai25zDLcUOWQWqVf/ QyVA== X-Forwarded-Encrypted: i=1; AJvYcCUCOkmb3O1JZN0LyiEt0krzwxKw9IVD9HOTQunc1HgcDP9g9lrCDu/sCGXk9phFZomJB1+9Avrk9i6K3XQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyEx9LyniLkt0n74kpo5Z8sRPfo7JVtX+Wsm3iSqKWiEd0z0IwN WWyIBM++Cty3feto1U8CV2Z36XnHyUQ74fBS1aJERyLcSdb366hpr/N7T0zgUcc= X-Google-Smtp-Source: AGHT+IGJ8O2nfVebXs/rTPoybsu6FDn6yseoR+E5sJTRxCOXXVZpsC04cUko3bF+v5+Uw1ma0m9ncw== X-Received: by 2002:a17:902:d585:b0:20b:a739:bd60 with SMTP id d9443c01a7336-20c6378d2acmr8950605ad.51.1728432310616; Tue, 08 Oct 2024 17:05:10 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 16/20] target/arm: Pass MemOp through get_phys_addr_twostage Date: Tue, 8 Oct 2024 17:04:49 -0700 Message-ID: <20241009000453.315652-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Pass memop through get_phys_addr_twostage with its recursion with get_phys_addr_nogpc. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 0445c3ccf3..f1fca086a4 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3301,7 +3301,7 @@ static bool get_phys_addr_disabled(CPUARMState *env, static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, vaddr address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { @@ -3313,7 +3313,8 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, ARMSecuritySpace ipa_space; uint64_t hcr; - ret = get_phys_addr_nogpc(env, ptw, address, access_type, 0, result, fi); + ret = get_phys_addr_nogpc(env, ptw, address, access_type, + memop, result, fi); /* If S1 fails, return early. */ if (ret) { @@ -3339,7 +3340,8 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, cacheattrs1 = result->cacheattrs; memset(result, 0, sizeof(*result)); - ret = get_phys_addr_nogpc(env, ptw, ipa, access_type, 0, result, fi); + ret = get_phys_addr_nogpc(env, ptw, ipa, access_type, + memop, result, fi); fi->s2addr = ipa; /* Combine the S1 and S2 perms. */ @@ -3469,7 +3471,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, if (arm_feature(env, ARM_FEATURE_EL2) && !regime_translation_disabled(env, ARMMMUIdx_Stage2, ptw->in_space)) { return get_phys_addr_twostage(env, ptw, address, access_type, - result, fi); + memop, result, fi); } /* fall through */ From patchwork Wed Oct 9 00:04:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827256 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 762AD36D for ; Wed, 9 Oct 2024 00:05:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432313; cv=none; b=ta8Fn+sdsGGm15GOuPOhAWltAPxZvNkKn8lpkIxHyL17yeeGJBIqmbMpj6AbIdeuHMEUA2fyHucZWnib4CpvfSJe+y9pDVuJp6IWDaha5ZE5suejDJhLzfMTl9qjQ+wXxM+7ku0Nj/GEr1bsEIs4weS18MgrllAY/d0ZFO1WniA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432313; c=relaxed/simple; bh=XXeh5EVLf/6WhaIHsqgYsIvJxVqgX+w1E9fSs98UHo8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F/TvLUUEB4i/tg3LPte6p1PdP0SIhmFdB45MgHQcnBxZpqzP9YdXjnehgYkycoZEZF2ArX1AgJv0Uu/W3ao2wW3q3diMQwZ3VcR0r5t2JFuKKpw2maA2ffFSaHTWOfDpv/dM61BGhoWKXB+TEl/AxBsvhWxMGv4vEpdMvAYBBC0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=WcuEX3de; arc=none smtp.client-ip=209.85.215.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WcuEX3de" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-7ea03ecf191so2488135a12.0 for ; Tue, 08 Oct 2024 17:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432312; x=1729037112; darn=vger.kernel.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=zDNpltdoK5BIHBCpA0bLYhC/fVRvo8Z+4KE41wqkR3g=; b=WcuEX3de8wsXc4/XWWKBdPO/qoorab1Lnlu3gVxVVLydHXuNf91KP1qP439++UAcjD GhmYGsZTNApJyAUGveHAkzEKpFP4V/lATzgv9LEsElbt8agx/widSHYdu9ai4a7j4F6s beq5oCB/QC2FUa9QxP61hPVUr/ayfbAuPY7cxQ1SQRyaGEfZ02MByBp3XxgtFQ1buGT9 si/xt0Amb4VKdklmMUR/yFb9KkuhlDqtrpErRtRcNw+KPScinmY4evtfOqZbwtVyzJrI 4LiBtc9OKPOAV3EmVXvPLZ/EaabYMRFrsQ2qGc5WcB7T+6omLzgwubDsRrhmFXHw2SnS frEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432312; x=1729037112; 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=zDNpltdoK5BIHBCpA0bLYhC/fVRvo8Z+4KE41wqkR3g=; b=ReJB2bLy5orT7dQdFRwbP68Nt4KnhNylWwz58egLeFR6zDmIQZ0FQdSiPfSJRmPcSl +45HRyUyZaLlL2XqVjwwOO2Xdd1JG3epKMw+in23QSjbMjpKPPy7M0py2x6JQBydOlN6 H+YaKtq/kcMVMKYgLW0tHOUQux5SdBeDzhhQvT8DPlfFJMDRqT7BRWhWcuEcLlc1yyLI u9cZb3D9w1X4jN/x+D8QRgoTzD/lg4te4Mysn02AEctCsvDUwAZbaf0MD3DttIf4LYaw kXFJIKuC8KDRG+AV8kSbnJe+3zz3jlTGjvbNEiC5xZ5w2s9MKuaSo12SccC/GbZdHDCG PGYQ== X-Forwarded-Encrypted: i=1; AJvYcCVejatWyKgIvVjR5Hw1yzSmQPHeeilkx44KgRr/UEZ1WtEXRgrk7NvmKL2WjJO96tjiArylVxxmrU7NEJM=@vger.kernel.org X-Gm-Message-State: AOJu0Yze8vVJB2oX2ksoCeyqhjmRWQhUwetjZBsB0CBCji6VTBWIp86q ZVBf0qnoQhu+XQC62bDfNiKjo+9/d/mFv8OlL8IUeexsuMDzoo0IsORV2fUYuqs= X-Google-Smtp-Source: AGHT+IF4BglkotazCAHqUPofHInFIYYYoctu9w4tOUz92qreZT9FiKqKTEYHHdQjaQVFF8PF0y1lkg== X-Received: by 2002:a17:902:da8d:b0:20b:c258:2a74 with SMTP id d9443c01a7336-20c6373ce07mr11388505ad.29.1728432311644; Tue, 08 Oct 2024 17:05:11 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org, Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 17/20] target/arm: Pass MemOp to get_phys_addr_lpae Date: Tue, 8 Oct 2024 17:04:50 -0700 Message-ID: <20241009000453.315652-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Pass the value through from get_phys_addr_nogpc. Reviewed-by: Helge Deller Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index f1fca086a4..238b2c92a9 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1684,12 +1684,13 @@ static bool nv_nv1_enabled(CPUARMState *env, S1Translate *ptw) * @ptw: Current and next stage parameters for the walk. * @address: virtual address to get physical address for * @access_type: MMU_DATA_LOAD, MMU_DATA_STORE or MMU_INST_FETCH + * @memop: memory operation feeding this access, or 0 for none * @result: set on translation success, * @fi: set to fault info if the translation fails */ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, uint64_t address, - MMUAccessType access_type, + MMUAccessType access_type, MemOp memop, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { ARMCPU *cpu = env_archcpu(env); @@ -3534,7 +3535,8 @@ static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, } if (regime_using_lpae_format(env, mmu_idx)) { - return get_phys_addr_lpae(env, ptw, address, access_type, result, fi); + return get_phys_addr_lpae(env, ptw, address, access_type, + memop, result, fi); } else if (arm_feature(env, ARM_FEATURE_V7) || regime_sctlr(env, mmu_idx) & SCTLR_XP) { return get_phys_addr_v6(env, ptw, address, access_type, result, fi); From patchwork Wed Oct 9 00:04:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827257 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B2FD383 for ; Wed, 9 Oct 2024 00:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432314; cv=none; b=hCQO7/OO+fnBwAVk/nR969eZPoISXECSU1yvqaCZaMzwIQT2p7EbQTZ3LQDFLMojBKjs5jZdILcQtaMv3Rlz83/gd+kt1qNB09aAWkhdhT7AmGMa0NOvKqecIABlB0OZGuCiPIKw2zncS/kXEGk6QFnf4PMV0GbxM3mNs3xIeTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432314; c=relaxed/simple; bh=uaZwcGJfviL3/sU4zyB9wfeakv2pmopAkplPZfK2uF4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DgkZLy9y1hL9KThiEvUbSS+WzgsapgiSITi2ibUP8NVqM7/1Doen/F04XTVSqXvF8Y6JizOmin3uBp/Re1ztVzcx0Mbb6L12dMzWdgRYqREjx3EK5aUCo1zj8OQztNNrWg3CTeL/XNOGbufTESsKiy/5ECBR8DfwEos0qhMBD70= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mv0aX9wl; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mv0aX9wl" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-20b833f9b35so54367685ad.2 for ; Tue, 08 Oct 2024 17:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432312; x=1729037112; darn=vger.kernel.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=oOELs1GBJLtlq8nQGFT7BbF8Y02om3aScvqBsVkX7+Q=; b=mv0aX9wl82W5IiJuOfP1p8k0FfVudNp8DaNC6ry+eYUILI0HQfy6O0P0olLoqkBAeZ 6nxPyqL4DepYA71D5VpD6JHo4Ldksl5B3Zc3TM0il3/f+GKZ2AQ4qlrQw+sgOXxQU1zB qZ/S0F8X04dHzh6P0Zo2/n6K6Q0J+vpEokc9vj4OCFleRR9LhfbOyDuJEz8xRnwd3ptC mJdCgVm/1A42aEv2hbSc5m4otWDnOnbrF6dtj8VveU3lXdbMXF4CVJxrRhImupaVFjGx nGn8z94cWezQ2gnrHxHnxrHezWT/Zd7Y3e/4QCiSm1FZmiW0cgi2llpf9BtvccbWLTWT GEAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432312; x=1729037112; 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=oOELs1GBJLtlq8nQGFT7BbF8Y02om3aScvqBsVkX7+Q=; b=RUfBxTLAeQFyxBjTuYg6Is56amAUFjIIANDP5ivXMsJcGJ7OqxI5DGv6QdUIqwggBN KSloEXwNDyVYHyyzBTZdjCfIcqSmsWmBzGWk8nVM+VdjDnb5AuFuhgVzYfWywRSF87ec /3jxMVPdEEiG/LA3If+dp1a1G7F4Ox0BOLjakeS1eJ93l6lOq4MCSBK7nhVy4/rm14+/ izEc40fjOCWCGpxlP0OGgxdoZciZYaEb0XiKQwJGwQRQNTmfgqF25pm9AmoNcQzP10Ec p8u/FhV+hksZA37tVcDWA2J27OL24uygWdSHO7SYkUoBP08FpRrP2haXEoVJIcBoEgcI Zoaw== X-Forwarded-Encrypted: i=1; AJvYcCUMn8iCVsKn+88AHuandfYFRIgF2ip/Apd/IE1UAaCZ5250poDx7bsGw8zx68wwOYmqxwCrhmvRRUOZeRA=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1oKWOMZxnPmATq4dUvTbjRP8LHPC/zkm7Hc4VCU8F9UgNtyel l9Hy4qDv/3WdrYN0lTuaa9SFp2ME+yAGf/ZoOkSAOz8wsqe/r3fK/EVangRJ3CQ= X-Google-Smtp-Source: AGHT+IGdLlh7lpqvQhrMnt+h4KRJVDHjJLBqhH4OV1XyMKMzeUf8I/qGPJ2X48D5Sn4234GTGJ8pPw== X-Received: by 2002:a17:902:ce91:b0:20b:54e5:e822 with SMTP id d9443c01a7336-20c6377b24fmr8881225ad.21.1728432312463; Tue, 08 Oct 2024 17:05:12 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH v3 18/20] target/arm: Move device detection earlier in get_phys_addr_lpae Date: Tue, 8 Oct 2024 17:04:51 -0700 Message-ID: <20241009000453.315652-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Determine cache attributes, and thence Device vs Normal memory, earlier in the function. We have an existing regime_is_stage2 if block into which this can be slotted. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 49 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 238b2c92a9..0a1a820362 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2029,8 +2029,20 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, xn = extract64(attrs, 53, 2); result->f.prot = get_S2prot(env, ap, xn, ptw->in_s1_is_el0); } + + result->cacheattrs.is_s2_format = true; + result->cacheattrs.attrs = extract32(attrs, 2, 4); + /* + * Security state does not really affect HCR_EL2.FWB; + * we only need to filter FWB for aa32 or other FEAT. + */ + device = S2_attrs_are_device(arm_hcr_el2_eff(env), + result->cacheattrs.attrs); } else { int nse, ns = extract32(attrs, 5, 1); + uint8_t attrindx; + uint64_t mair; + switch (out_space) { case ARMSS_Root: /* @@ -2102,6 +2114,19 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, */ result->f.prot = get_S1prot(env, mmu_idx, aarch64, ap, xn, pxn, result->f.attrs.space, out_space); + + /* Index into MAIR registers for cache attributes */ + attrindx = extract32(attrs, 2, 3); + mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; + assert(attrindx <= 7); + result->cacheattrs.is_s2_format = false; + result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8); + + /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */ + if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { + result->f.extra.arm.guarded = extract64(attrs, 50, 1); /* GP */ + } + device = S1_attrs_are_device(result->cacheattrs.attrs); } if (!(result->f.prot & (1 << access_type))) { @@ -2131,30 +2156,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, result->f.attrs.space = out_space; result->f.attrs.secure = arm_space_is_secure(out_space); - if (regime_is_stage2(mmu_idx)) { - result->cacheattrs.is_s2_format = true; - result->cacheattrs.attrs = extract32(attrs, 2, 4); - /* - * Security state does not really affect HCR_EL2.FWB; - * we only need to filter FWB for aa32 or other FEAT. - */ - device = S2_attrs_are_device(arm_hcr_el2_eff(env), - result->cacheattrs.attrs); - } else { - /* Index into MAIR registers for cache attributes */ - uint8_t attrindx = extract32(attrs, 2, 3); - uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; - assert(attrindx <= 7); - result->cacheattrs.is_s2_format = false; - result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8); - - /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */ - if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { - result->f.extra.arm.guarded = extract64(attrs, 50, 1); /* GP */ - } - device = S1_attrs_are_device(result->cacheattrs.attrs); - } - /* * Enable alignment checks on Device memory. * From patchwork Wed Oct 9 00:04:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827258 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18F47801 for ; Wed, 9 Oct 2024 00:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432315; cv=none; b=WeQ5qjA65KV0VwlRIDqtSaxSNnOiaXiJ2A03oqqKFTmIRhbblReVwz6izMeO6bF5jGum0w163zjmMRvcSa4FVC8DKTxEfmh3QCYbjU+gKOnUKZf0FeeJPoJPYqSTRhUeS/n09/LL/78aafe24z+nWTbPbly42cfucyyZ4MyzEF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432315; c=relaxed/simple; bh=KCJU+G3UMNY8XDo2GlrX6CIIkydSd/xelA/wJkWMaeI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KNcvOnSBqiCtwS63o4kIbl0xOradux75WPVjsnEo1nofTEaXi4Xi+MUKL4/mmbfDndgrv47RXi+9mQMhTd7eTmjPwcon3vzzOApReuiqGGcoFe7n/L++yjuDiJzqU9dJUM4S4COSvm9r8MEG9PSCQBLJSGZrJrq6OdELGOJ59qE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=XVv9i+kn; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XVv9i+kn" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-20c5a7b2908so9764945ad.1 for ; Tue, 08 Oct 2024 17:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432313; x=1729037113; darn=vger.kernel.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=AsNmQx87g0SWMKNuiqJxyPNh2jiF8Ss0MC8Fky2xo4U=; b=XVv9i+kn5doMniFDiynQfXH3hiU1LThg0mn+eyHQMHnUhCkjIWU/H5H8/glrSuJMYw /7zfDhpues70HNN7TGc1AgdagMJISImURKjkQyEr6HAY1Q1/N6mZ16ADJWu4regL74tM uShI743vdtF1Od3y1byGPgyIhBr35e0I1FKPC0T26hwcKu66CVATh179k7LWzxPy7mFD u1uJbW6JzCEo7PkPmvFFOXkfRn+aAhCTOmqWTPGjrd5L6Zj71hl9O40g8nqK3vwf8OOc SfEdz7pmsfIeaChMU369HKR8soY9VMlcgJW9WEAhVRNWKIonjNN5D5GRBJQZzCkVSdrc QZyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432313; x=1729037113; 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=AsNmQx87g0SWMKNuiqJxyPNh2jiF8Ss0MC8Fky2xo4U=; b=wZ/LIa7w289aWziU2ci1ZfC5KoQ9wNM2jnnrULkog6CXWGGjoR9HpWokplM1POzNO/ +TVGJt/5voIphsIBUpzKBBNXuZy+9AB5P2z3et7HPW3teTUqDZxndt2DX8/Nttgb1k3O 3gh0KSVVMBaIznERodDH6nu7ew1KTH3rnLhqrUjRYJ/U5Ie9qIzfY+ijiNB4CtOt/jpB W7B1i8fzxvVhOHtZ9kH/H0rJA0aGXZdq1gCqWlDWtwwVsTkq7fEV5dS9inz4iW5dGY8x xorSUIGPeJN7hk1CXtwqvgtVgjhG9M14cU3Lsn0nJVuMJhmX7e3B1Nru8hngLlGF5ZIV 2hyA== X-Forwarded-Encrypted: i=1; AJvYcCWDEKqKPNYI9OAtkHM3MBy1aEdI/I3Wd4R3R4OBHF1tC97g2haxU7rQqJUXrMu7F3hMAu3H1NDQUDAvQLw=@vger.kernel.org X-Gm-Message-State: AOJu0Yxi20gqrVufW8mqPFP+3UB9C7VbrCOc1icbATh89Pjzu0vcPhS+ Bjxam6/2VzmP7rS2K87adwHUgcorovdAtsXn/yHMtQXIesaF22nVgOH73S7ID+emsBg3K+0DsE8 + X-Google-Smtp-Source: AGHT+IFwettQe3bNvU+s7lxTJSvr2zVnYgznFgHUWVsZdUYFjaAq3kofjLpeFOF7iswFe+1y64JOcA== X-Received: by 2002:a17:903:228a:b0:20c:5a64:9bc6 with SMTP id d9443c01a7336-20c6378e9c4mr11368345ad.50.1728432313486; Tue, 08 Oct 2024 17:05:13 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH v3 19/20] target/arm: Implement TCGCPUOps.tlb_fill_align Date: Tue, 8 Oct 2024 17:04:52 -0700 Message-ID: <20241009000453.315652-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fill in the tlb_fill_align hook. Handle alignment not due to memory type, since that's no longer handled by generic code. Pass memop to get_phys_addr. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/internals.h | 6 ++--- target/arm/cpu.c | 2 +- target/arm/tcg/cpu-v7m.c | 2 +- target/arm/tcg/tlb_helper.c | 49 ++++++++++++++----------------------- 4 files changed, 24 insertions(+), 35 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index a6088d551c..299a96a81a 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -816,9 +816,9 @@ void arm_cpu_record_sigsegv(CPUState *cpu, vaddr addr, void arm_cpu_record_sigbus(CPUState *cpu, vaddr addr, MMUAccessType access_type, uintptr_t ra); #else -bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); +bool arm_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr addr, + MMUAccessType access_type, int mmu_idx, + MemOp memop, int size, bool probe, uintptr_t ra); #endif static inline int arm_to_core_mmu_idx(ARMMMUIdx mmu_idx) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 19191c2391..1320fd8c8f 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2663,7 +2663,7 @@ static const TCGCPUOps arm_tcg_ops = { .record_sigsegv = arm_cpu_record_sigsegv, .record_sigbus = arm_cpu_record_sigbus, #else - .tlb_fill = arm_cpu_tlb_fill, + .tlb_fill_align = arm_cpu_tlb_fill_align, .cpu_exec_interrupt = arm_cpu_exec_interrupt, .cpu_exec_halt = arm_cpu_exec_halt, .do_interrupt = arm_cpu_do_interrupt, diff --git a/target/arm/tcg/cpu-v7m.c b/target/arm/tcg/cpu-v7m.c index 5496f14dc1..58e54578d6 100644 --- a/target/arm/tcg/cpu-v7m.c +++ b/target/arm/tcg/cpu-v7m.c @@ -242,7 +242,7 @@ static const TCGCPUOps arm_v7m_tcg_ops = { .record_sigsegv = arm_cpu_record_sigsegv, .record_sigbus = arm_cpu_record_sigbus, #else - .tlb_fill = arm_cpu_tlb_fill, + .tlb_fill_align = arm_cpu_tlb_fill_align, .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt, .cpu_exec_halt = arm_cpu_exec_halt, .do_interrupt = arm_v7m_cpu_do_interrupt, diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c index 1d8b7bcaa2..8841f039bc 100644 --- a/target/arm/tcg/tlb_helper.c +++ b/target/arm/tcg/tlb_helper.c @@ -318,14 +318,13 @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, arm_deliver_fault(cpu, addr, access_type, mmu_idx, &fi); } -bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) +bool arm_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr address, + MMUAccessType access_type, int mmu_idx, + MemOp memop, int size, bool probe, uintptr_t ra) { ARMCPU *cpu = ARM_CPU(cs); GetPhysAddrResult res = {}; ARMMMUFaultInfo local_fi, *fi; - int ret; /* * Allow S1_ptw_translate to see any fault generated here. @@ -339,37 +338,27 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, } /* - * Walk the page table and (if the mapping exists) add the page - * to the TLB. On success, return true. Otherwise, if probing, - * return false. Otherwise populate fsr with ARM DFSR/IFSR fault - * register format, and signal the fault. + * Per R_XCHFJ, alignment fault not due to memory type has + * highest precedence. Otherwise, walk the page table and + * and collect the page description. */ - ret = get_phys_addr(&cpu->env, address, access_type, 0, - core_to_arm_mmu_idx(&cpu->env, mmu_idx), - &res, fi); - if (likely(!ret)) { - /* - * Map a single [sub]page. Regions smaller than our declared - * target page size are handled specially, so for those we - * pass in the exact addresses. - */ - if (res.f.lg_page_size >= TARGET_PAGE_BITS) { - res.f.phys_addr &= TARGET_PAGE_MASK; - address &= TARGET_PAGE_MASK; - } - + if (address & ((1 << memop_alignment_bits(memop)) - 1)) { + fi->type = ARMFault_Alignment; + } else if (!get_phys_addr(&cpu->env, address, access_type, memop, + core_to_arm_mmu_idx(&cpu->env, mmu_idx), + &res, fi)) { res.f.extra.arm.pte_attrs = res.cacheattrs.attrs; res.f.extra.arm.shareability = res.cacheattrs.shareability; - - tlb_set_page_full(cs, mmu_idx, address, &res.f); + *out = res.f; return true; - } else if (probe) { - return false; - } else { - /* now we have a real cpu fault */ - cpu_restore_state(cs, retaddr); - arm_deliver_fault(cpu, address, access_type, mmu_idx, fi); } + if (probe) { + return false; + } + + /* Now we have a real cpu fault. */ + cpu_restore_state(cs, ra); + arm_deliver_fault(cpu, address, access_type, mmu_idx, fi); } #else void arm_cpu_record_sigsegv(CPUState *cs, vaddr addr, From patchwork Wed Oct 9 00:04:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13827259 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 154ED36D for ; Wed, 9 Oct 2024 00:05:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432316; cv=none; b=inlhBc1srl5XK8r6+7HMNdt3xOLYP66UrtcevlhSZvPhBU40F0ZOeP+0kMPWny3GEu13+pGCykH5nuCa73Mf4trQ1dYzlPDhCZYXLhyDDM/JsguMCt2jtt1YwgXOwYgOau/XKgV6vFkYtcyeZW+pOBt4cNlSxZVPsI70w9Odz4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728432316; c=relaxed/simple; bh=Dvf8kAmrTC1rCzQu2thxtOdg4DFg7JeF+YLgWsBAI6k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BssVB4/1gLzu0ZidSjt6qLv7P2TqfAVY6ET+NVgqoEwtvbQr8rRYn/xi2+yb96D9Ue/EnkGy/XAlvgUdwDLapFJYnwKVx378AaMSfQsaieiGHKl1tvd4NV/6ObRNn1p/Kn8pwMjhrbY8Rye8FnA6/f8iB0VTuO8s0vZbgJGxfUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Me8dllmP; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Me8dllmP" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-20bc506347dso49905815ad.0 for ; Tue, 08 Oct 2024 17:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728432314; x=1729037114; darn=vger.kernel.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=G2SEeBS4yBn5Ue1nQmA6MrWE5kNjL002NNNwwbKYNls=; b=Me8dllmPtUilU3WMP+iK2cVFOnl7wspXSAIPXxns2mh0rOLsdNLHtp3W1PrJ3gP9kD Ot1sdrw0IA3U6DdvDQPxU+kTeepaFd4FxP2wXLBEpYKRA/WG+/LZVEOo6HUl+KYDRTiT 1KLlFeOBAfLkSrLgDH2TOdJ6v+XEdwAk29Jc0iMlfNcf07sZNEwumkORoigQtURJuGTh sGWzsmaC5B1sHVIZT887Ffy7nR/Wx83tlLJOL6vo3dq7ht0TElh2aqoU741oGCdIDZ57 kxGIontP4xxP507G3Gn2p60RvkNxgPy18wj10nCvGUslqhHPLsTn8sktxsFe/dbxIfZn UbQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728432314; x=1729037114; 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=G2SEeBS4yBn5Ue1nQmA6MrWE5kNjL002NNNwwbKYNls=; b=dnvGvraqWPta/HK5WN5WbrkXj8EFhHYr3NL1P6CQFhNDxzr+EEgaEmKSqJtsGOeL6T u/Ovps/qHhpZrGmYIRu3UASlnr7g7n+vGIuBvFCmjXIgjfbYvbLhoZDV8KVTqWw8GPTe yJYmeRioQ5eTbGMH8nMFVpJblO3z34sOeFG+bfXVAf6QdK0EAyHzImAO3BxUr88afDUQ ZmZbqtGUUM/Pu1kERqE2lMYEaLA4LybBH+LX9KVB3XpijiH/vkD2HgTOHzls5NIwxIlO ulKebGVwRzntjdmLeq8eopwSt6kB7cfw/8LOUCZ6NV6eiOESdTAXMQNjSkXfz87GamsJ S51Q== X-Forwarded-Encrypted: i=1; AJvYcCWO3sv6NIvCV3SYes25X4xuIKCXM/3suvreAbMW7dJGA1v5PZUTvYMnQUnUFanSW09bOCldnyQAVavAw6U=@vger.kernel.org X-Gm-Message-State: AOJu0Yx52i4/PdVxo8DjPAJBKaW809bsGN/eu+qJxjtDK+lAk6c6M4jE fskyymAY0AkbfvlbzKBMB7FTKvuoIDbZqC0s1F2d7C0JDt4vnG+2GEjCOrmx44o8u8oSoWU1H5L r X-Google-Smtp-Source: AGHT+IEIyXlGp9GlJJjjmIJWjUJQUjNDGcChOdkRVTwHuAzsY/hOJnshLN76/ClOQ0ILuClUnw979g== X-Received: by 2002:a17:903:22ce:b0:20b:a5b5:b89 with SMTP id d9443c01a7336-20c63751f24mr14941525ad.35.1728432314287; Tue, 08 Oct 2024 17:05:14 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cecf2sm60705105ad.104.2024.10.08.17.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:05:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH v3 20/20] target/arm: Fix alignment fault priority in get_phys_addr_lpae Date: Tue, 8 Oct 2024 17:04:53 -0700 Message-ID: <20241009000453.315652-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009000453.315652-1-richard.henderson@linaro.org> References: <20241009000453.315652-1-richard.henderson@linaro.org> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that we have the MemOp for the access, we can order the alignment fault caused by memory type before the permission fault for the page. For subsequent page hits, permission and stage 2 checks are known to pass, and so the TLB_CHECK_ALIGNED fault raised in generic code is not mis-ordered. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 51 ++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 0a1a820362..dd40268397 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2129,6 +2129,36 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, device = S1_attrs_are_device(result->cacheattrs.attrs); } + /* + * Enable alignment checks on Device memory. + * + * Per R_XCHFJ, the correct ordering for alignment, permission, + * and stage 2 faults is: + * - Alignment fault caused by the memory type + * - Permission fault + * - A stage 2 fault on the memory access + * Perform the alignment check now, so that we recognize it in + * the correct order. Set TLB_CHECK_ALIGNED so that any subsequent + * softmmu tlb hit will also check the alignment; clear along the + * non-device path so that tlb_fill_flags is consistent in the + * event of restart_atomic_update. + * + * In v7, for a CPU without the Virtualization Extensions this + * access is UNPREDICTABLE; we choose to make it take the alignment + * fault as is required for a v7VE CPU. (QEMU doesn't emulate any + * CPUs with ARM_FEATURE_LPAE but not ARM_FEATURE_V7VE anyway.) + */ + if (device) { + unsigned a_bits = memop_atomicity_bits(memop); + if (address & ((1 << a_bits) - 1)) { + fi->type = ARMFault_Alignment; + goto do_fault; + } + result->f.tlb_fill_flags = TLB_CHECK_ALIGNED; + } else { + result->f.tlb_fill_flags = 0; + } + if (!(result->f.prot & (1 << access_type))) { fi->type = ARMFault_Permission; goto do_fault; @@ -2156,27 +2186,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, result->f.attrs.space = out_space; result->f.attrs.secure = arm_space_is_secure(out_space); - /* - * Enable alignment checks on Device memory. - * - * Per R_XCHFJ, this check is mis-ordered. The correct ordering - * for alignment, permission, and stage 2 faults should be: - * - Alignment fault caused by the memory type - * - Permission fault - * - A stage 2 fault on the memory access - * but due to the way the TCG softmmu TLB operates, we will have - * implicitly done the permission check and the stage2 lookup in - * finding the TLB entry, so the alignment check cannot be done sooner. - * - * In v7, for a CPU without the Virtualization Extensions this - * access is UNPREDICTABLE; we choose to make it take the alignment - * fault as is required for a v7VE CPU. (QEMU doesn't emulate any - * CPUs with ARM_FEATURE_LPAE but not ARM_FEATURE_V7VE anyway.) - */ - if (device) { - result->f.tlb_fill_flags |= TLB_CHECK_ALIGNED; - } - /* * For FEAT_LPA2 and effective DS, the SH field in the attributes * was re-purposed for output address bits. The SH attribute in