From patchwork Fri May 5 01:02:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 679282 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp92076wrs; Thu, 4 May 2023 18:14:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Rxu2FzvUzd4Rlhe9yvEG1yC6gnWGzEV90/xJuOgIdFIbA2l39lMJBwSC6spmS7dtjrm+x X-Received: by 2002:a05:622a:15cd:b0:3e6:3929:e9bc with SMTP id d13-20020a05622a15cd00b003e63929e9bcmr311064qty.6.1683249252219; Thu, 04 May 2023 18:14:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683249252; cv=none; d=google.com; s=arc-20160816; b=Uzy5sfvy3PHWTwHaS+Mcf0EOYeaabNbpcviglGZ4HViFyOkDYhvoDmMeHOUtRGh+NJ MWanQEbHXihI3P7DzRnngbYnzWMakTX+pvV18PRbR8t5sMuDSlsTXQrx7m6iiA0ZmBrN FnXlGrkcOh2tojrit8XcK1BpdpiqO/6cZ4equCZtWOhOfSFHcu7r3Wj6NF6Rpa6abMyR 6RyNOqtWnLzABj/YRpnWp8JlbWhIaDdRN+MNHppDc+biv3mEm8GEH85qWiBJEBRRo+Gy V7CffNQwyah3puMrOqr3wdqDk/BKro0b1MM7pGFMIK8xhUVrqoQ7ifLTcGdMzoYuXEgq Gkeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ULqMf+DmHpGYNoo8G2xP3dFFiX1NCkBJ2cATdvrFXCY=; b=mAeQUym9E+tDLxjcdQjh1M5Zr9/+rieULeZiYr3nyVHe1OjPmvFtIuxgm2FYvn1SR8 iGneHDUdY4bcJcfkzKYyKTs4jSqCB3eCFmvq4KRAqp1V7ZDw2oiiNDsx6xtB/d81pVhV bRu6gRzGP80YQ9ai0eEcjjU+VwWaj/TMb//ylZI0XH0wiq+6h74xfZr3X1K2NsZgpF4V I7dWiuaGCx9oIUU780FSCZ0/uXGGqW1Ezu+onb1/4Qmnt5gJpPX+MKaE7r1hhJq7/jJR POhX1gLiy7WwawoLhDnyupayfCQBVFrRoyE0Js0ltx7XlGOMYTXEd5FFfHGjft0C6OVj 0C5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=UFpTT5t3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 18-20020a05620a079200b0074a3b8b12f5si244919qka.350.2023.05.04.18.14.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 May 2023 18:14:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=UFpTT5t3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pujva-0001BH-RG; Thu, 04 May 2023 21:08:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pujvS-00011C-6S for qemu-devel@nongnu.org; Thu, 04 May 2023 21:07:59 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pujvQ-00086q-AK for qemu-devel@nongnu.org; Thu, 04 May 2023 21:07:57 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-52c6f8ba7e3so1040759a12.3 for ; Thu, 04 May 2023 18:07:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683248871; x=1685840871; 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=ULqMf+DmHpGYNoo8G2xP3dFFiX1NCkBJ2cATdvrFXCY=; b=UFpTT5t34Xg5CEAuNdq4XtN+GCTTgBcfGpiyVBwva1i1hA9UsLq+P7BNyyp5NqdoHG v6uLEIrH/N+5hm+Jiaar4U0tSdv8YLISPU0uKwd3usLFaU3mPWByL+rJeIypvSeGmBIq Eqa2d/UJlniTTDyu+HWeI3x1TDjyzlCp4Enp1SlKjMSTF950ftgfWM91GAzKeWJxU9hb 0iP6JnvlChy35/Ir4d7ZlH9JWQvqys7cqy+g9kux4kQmZRuqscs4FX2FSHwQcxBm+jNF fDaWmyUbXB74L5NzjQX24CtD950TNEKIQfeLYihdmDn59y1EDzoKODtB4QOYV9sDHF+O l9mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683248871; x=1685840871; 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=ULqMf+DmHpGYNoo8G2xP3dFFiX1NCkBJ2cATdvrFXCY=; b=CTl8rTPnee4NmQyk/cLw4hWQ/r3vodLluHFFYJmhUhTLdeN7zQtHlSY7oV/XYOiyhs 3qYEIt/D6SS3irLHNNCmMurhtf8Oep2DXZ0BOwS3Bxz4Fp8z9srgrUd1hqcNrYFIuqL5 f4X9ljBZL03nW70fXIEED57e+W0lpxNUclZHkJSzb4xsG6ys6CjyT53METZDj3a78+yC 8YKDz6rph9IKzPVtxWVF7VgTXyX9o3CsV1QiMHeLVX3p9Mgfykn5AB8mnmWUdOJIWzr8 DTbk7R6Tg0w9Iss7DQH/45wCdoaWhyygN8VMzsbBjf4sei6zyN5NBnWhFSGQpUUqDClx tfzQ== X-Gm-Message-State: AC+VfDxZNhT+djsjzFO5IkeXjZLQVyf4Ox19sEGWaycZ1oysalHxsvH/ x6RudDiqGx4sTmFU35Wd1gnzPk+DHIOLlA== X-Received: by 2002:a17:902:e54b:b0:1a6:9f9b:1327 with SMTP id n11-20020a170902e54b00b001a69f9b1327mr6782305plf.45.1683248871524; Thu, 04 May 2023 18:07:51 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id l19-20020a170902d35300b0019309be03e7sm218762plk.66.2023.05.04.18.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 18:07:50 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , Weiwei Li , Daniel Henrique Barboza Subject: [PULL 79/89] target/riscv: Merge checks for reserved pte flags Date: Fri, 5 May 2023 11:02:31 +1000 Message-Id: <20230505010241.21812-80-alistair.francis@wdc.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230505010241.21812-1-alistair.francis@wdc.com> References: <20230505010241.21812-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=alistair23@gmail.com; helo=mail-pg1-x52e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Weiwei Li Tested-by: Daniel Henrique Barboza Message-Id: <20230325105429.1142530-24-richard.henderson@linaro.org> Message-Id: <20230412114333.118895-24-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/cpu_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 9a2b944990..c7c384bae3 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -962,14 +962,14 @@ restart: /* Reserved without Svpbmt. */ return TRANSLATE_FAIL; } - if ((pte & (PTE_R | PTE_W | PTE_X)) == PTE_W) { - /* Reserved leaf PTE flags: PTE_W */ - return TRANSLATE_FAIL; - } - if ((pte & (PTE_R | PTE_W | PTE_X)) == (PTE_W | PTE_X)) { - /* Reserved leaf PTE flags: PTE_W + PTE_X */ + + /* Check for reserved combinations of RWX flags. */ + switch (pte & (PTE_R | PTE_W | PTE_X)) { + case PTE_W: + case PTE_W | PTE_X: return TRANSLATE_FAIL; } + if ((pte & PTE_U) && ((mode != PRV_U) && (!sum || access_type == MMU_INST_FETCH))) { /*