From patchwork Sat Feb 29 01:28:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 184046 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp1373411ile; Fri, 28 Feb 2020 17:32:13 -0800 (PST) X-Google-Smtp-Source: APXvYqwrWB4dTgCLK1RUXw804UIxvHib2QTONqJ4Rs7zh3lkPxhMenxOjrX/MWvPnIt5IO19Y0px X-Received: by 2002:a05:620a:1129:: with SMTP id p9mr6982331qkk.123.1582939933550; Fri, 28 Feb 2020 17:32:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582939933; cv=none; d=google.com; s=arc-20160816; b=gdMGYzS8WAgOIwDgpt00Hc1jhoH8M6UyeoICTRnQ+3rWa7NAhMb0a6zc1IfgSXeuYE RUkf+0WMCIIgDR6uU5KL/Xq8Jav7YJcSBAf0Fu4iWPP1JxIJZW9aEv+vQmxZwwSi+5yQ +nGZ58yhKnrNxn6OflpdF/sWtQg3cOeW8zrsJKhkjh7uD36j+xiuuzDM+HQBaKEu3UdB Nx/UDI53afNsudmSi96EfecHN2ZnO7oK7oRLVEoEoN4Fi61kf6No+yxvw1urM7xpydE4 FdqxUxojO3KTDGO4Jb0jsciovKRPlWmmLDaUFcH6yCcraE/l53DBJ9HEV2TDHhuhC1ng szeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=pnBsdmgd+K1Yf7h5c1j8apGf/ntIFnarc7b46/SCqJo=; b=O59YQIeXGMOjODZiRpyQIPv9VretvrjXg5b283a25f3lJ+tUNcr88EPv+kdrzWVbpU jQ8F3/hCh8Oi22TnYBQcf1tpEM5hg2RSrQ8Weth+6s0yAla3WTtiJmvn8NJNV1huain6 +EvmlhoaeIQ2bzqlFXjvDju9gMxQj0JBHY7KBN9/Iq78pH/W/pIa/ur36kIWtq7e2kRC 14Mz4viRZKRX3j+KBe30c4LzRzOM9bgObzzApxwyYimlfvzE4dobkjforMx21EB3yLEO 6XUJY4sXbPISegxOOdCigSyetZf8F6L75kACeHf8OUCPhod6GaiNuZTrysv98Soyy6kB CJqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QBuCvpGz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w6si2242370qvp.130.2020.02.28.17.32.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Feb 2020 17:32:13 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QBuCvpGz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7qzE-0004At-Tf for patch@linaro.org; Fri, 28 Feb 2020 20:32:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37145) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7qvd-0004wC-UO for qemu-devel@nongnu.org; Fri, 28 Feb 2020 20:28:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7qvc-00066U-95 for qemu-devel@nongnu.org; Fri, 28 Feb 2020 20:28:29 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:40960) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7qvc-00065m-1p for qemu-devel@nongnu.org; Fri, 28 Feb 2020 20:28:28 -0500 Received: by mail-pf1-x444.google.com with SMTP id j9so2588854pfa.8 for ; Fri, 28 Feb 2020 17:28:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pnBsdmgd+K1Yf7h5c1j8apGf/ntIFnarc7b46/SCqJo=; b=QBuCvpGzy1XivFgp2aDM3fsm+2gH6Fl0PX8pu1kV41V77kWcY9sUpwrkX15ZFcbRcw zGXkN3wkBtzNoyogNyqJeKA9PNaaTEICnvyKZJwMiGLEvbcewhOzWiqGzK8gy1tgUHGy fenHV+zqcl5fH2ypRZ8oXvWu4jQ8g9Dr8NhH+2G+dbb4Ha4nasGT8lnm2Xe2DClqFVS6 OKBqoQb4SocdD1aNzmwqtPqJLlgY2bdrqJRILqruCRmca4Vluvsu8EXS3GPldYWILuJL RjwJbYj41JavXRFzzoRMgv0Wj8fPvsmy2pT0zPeks3DF8JlfR65FZhP0b1euVbj+uzS6 GFMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pnBsdmgd+K1Yf7h5c1j8apGf/ntIFnarc7b46/SCqJo=; b=Tx/y9PvjFCEWYIkxRkeunzuxft0lMGVPtOiz3+8ap4ais4xe0kHho096km8WrpI1jq vsD5BCZMZBz+KoXSHnkgsNnSmtEbVi2sXhYAgueJy8WoFyiXtBIphxBm0HHUq5vVbzah Ks8ln2uDU/7zyFYuZC8ZjYdBrDBVE7vHLHsAZgThxC0bFe6KoG7MfKnHXhrmpzIgRHcu b06tx5w4hbTVM9m8GmvrJ+/gqgDVlbN7R6mvb4/ZpTAIvopsdPb+vJ1d7RYaM2wNbI8j lTRW9Lb+q6VSB9Eme3e2VWEnK4PIzzvT6g4t8bFa0fcRQE1etwlyX4Yp+leQOMkU9eWS RA5Q== X-Gm-Message-State: APjAAAUkn2Sk4we3+1OqfHGuqD4bQB/lFMBbWbWGRQhVjPItmxhUi86O kEwS8HWWUPSrfokCQLLZ3NcP14nFEDY= X-Received: by 2002:aa7:93a6:: with SMTP id x6mr7236480pff.72.1582939706213; Fri, 28 Feb 2020 17:28:26 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id r3sm4606313pfq.126.2020.02.28.17.28.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 17:28:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 09/12] target/arm: Honor the HCR_EL2.TPCP bit Date: Fri, 28 Feb 2020 17:28:08 -0800 Message-Id: <20200229012811.24129-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200229012811.24129-1-richard.henderson@linaro.org> References: <20200229012811.24129-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This bit traps EL1 access to cache maintenance insns that operate to the point of coherency or persistence. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v3: Fix el0 fallthru (pmm). --- target/arm/helper.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 2c06ac8d02..e87a76c6f5 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4314,6 +4314,28 @@ static CPAccessResult aa64_cacheop_access(CPUARMState *env, return CP_ACCESS_OK; } +static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env, + const ARMCPRegInfo *ri, + bool isread) +{ + /* Cache invalidate/clean to Point of Coherency or Persistence... */ + switch (arm_current_el(env)) { + case 0: + /* ... EL0 must UNDEF unless SCTLR_EL1.UCI is set. */ + if (!(arm_sctlr(env, 0) & SCTLR_UCI)) { + return CP_ACCESS_TRAP; + } + /* fall through */ + case 1: + /* ... EL1 must trap to EL2 if HCR_EL2.TPCP is set. */ + if (arm_hcr_el2_eff(env) & HCR_TPCP) { + return CP_ACCESS_TRAP_EL2; + } + break; + } + return CP_ACCESS_OK; +} + /* See: D4.7.2 TLB maintenance requirements and the TLB maintenance instructions * Page D4-1736 (DDI0487A.b) */ @@ -4721,14 +4743,15 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .accessfn = aa64_cacheop_access }, { .name = "DC_IVAC", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, - .access = PL1_W, .type = ARM_CP_NOP }, + .access = PL1_W, .accessfn = aa64_cacheop_poc_access, + .type = ARM_CP_NOP }, { .name = "DC_ISW", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2, .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, { .name = "DC_CVAC", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NOP, - .accessfn = aa64_cacheop_access }, + .accessfn = aa64_cacheop_poc_access }, { .name = "DC_CSW", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, @@ -4739,7 +4762,7 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "DC_CIVAC", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NOP, - .accessfn = aa64_cacheop_access }, + .accessfn = aa64_cacheop_poc_access }, { .name = "DC_CISW", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, @@ -4921,17 +4944,17 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "BPIMVA", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 7, .type = ARM_CP_NOP, .access = PL1_W }, { .name = "DCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, { .name = "DCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2, .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, { .name = "DCCMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 1, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, { .name = "DCCSW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, { .name = "DCCMVAU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 11, .opc2 = 1, .type = ARM_CP_NOP, .access = PL1_W }, { .name = "DCCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 1, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, { .name = "DCCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, /* MMU Domain access control / MPU write buffer control */ @@ -6750,7 +6773,7 @@ static const ARMCPRegInfo dcpop_reg[] = { { .name = "DC_CVAP", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, - .accessfn = aa64_cacheop_access, .writefn = dccvap_writefn }, + .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, REGINFO_SENTINEL }; @@ -6758,7 +6781,7 @@ static const ARMCPRegInfo dcpodp_reg[] = { { .name = "DC_CVADP", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, - .accessfn = aa64_cacheop_access, .writefn = dccvap_writefn }, + .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, REGINFO_SENTINEL }; #endif /*CONFIG_USER_ONLY*/