From patchwork Mon Dec 3 20:38:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152738 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7268504ljp; Mon, 3 Dec 2018 12:39:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/WnUjr4Y4+2HbQgo2YqMEH0ng2onICk3uLjvr/GEMIFJpTTTm7fFehHbYXxwc/wn9c9ZirE X-Received: by 2002:a37:bb05:: with SMTP id l5mr16044454qkf.305.1543869569105; Mon, 03 Dec 2018 12:39:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543869569; cv=none; d=google.com; s=arc-20160816; b=V7pogGCQZ1NKmRpUKaM//p4dJ2u+Xe30/sE0E0e6Yqms8yARHKmYJouJkClMNltHn6 wQ1peJoUt/e4q01r5NgUuje6fyGMMZyp17AG6kkVb52XG/nIyOXZtVkfeRLlv8qKuuWD D6r5e/ON7wQR5/nxJzmavYEMKPXU3M0DX9zxwFpFuxm8f4xFvDUZK8DRO7/z6cxfKFzv EaYwRNeqo8aGX/TkvhWomz28r5dBuNdloTcLp2iJuGs+U9aF7JPMK4Ii4ltkA0RRhFWL mjpIlFvO95Eo8d6ZbTUZsFXQ6dZJV6qLqRN7wpKmEQIdBhJfB4a42Ysgqnzv6NFfP2M7 bnfg== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=K0xlyMQ/dOYdblPn1aCAZbPODNQLh5ktdiFooUbCPzE=; b=lGeL0cmvjgAlAr7FpOaeowdascUZVA9thONV/DzPy4XlqdhBMznCSB2/5S8WeBUwMY mKQ1nS/O3f+F8xtC5l3ea/1SOxJSAW/5dKZBS4+zFkNe2ARSpMQYKI2ZbGEaD5kEkR50 OW9vJSJ6IHiXY0ndgwq8XSKpga7VCG3V0tFtmxe+KflPRxMhPki/i8+yr2XjsoYuy60A yQB3PK8js+WeOSGDNoUIAk04sChmOqSsbN6yhhG7Q7oSCIu9UugcUOWlytFFB4pALqOM 6BZPZusKw7zIhMnKPfhzhISUIQmKiy1SdfNT+HlRO55zmI9FXWQqAb8QYYT+3BIqLmHl r+tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=S1h6BbL1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m96si7555388qte.185.2018.12.03.12.39.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 03 Dec 2018 12:39:29 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=S1h6BbL1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTv04-0006Ad-EE for patch@linaro.org; Mon, 03 Dec 2018 15:39:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTuzb-000687-5q for qemu-devel@nongnu.org; Mon, 03 Dec 2018 15:39:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTuza-0005sz-7V for qemu-devel@nongnu.org; Mon, 03 Dec 2018 15:38:59 -0500 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:37154) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gTuza-0005sF-2t for qemu-devel@nongnu.org; Mon, 03 Dec 2018 15:38:58 -0500 Received: by mail-oi1-x242.google.com with SMTP id y23so12231279oia.4 for ; Mon, 03 Dec 2018 12:38:58 -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; bh=K0xlyMQ/dOYdblPn1aCAZbPODNQLh5ktdiFooUbCPzE=; b=S1h6BbL1bWOjEfCgXkfg3j+hkmuxPoh8no1qIVDDwnLP8u8h9QbYYj4oAvILbylNfE VY4TROiwlIuWgiQNh/ZBpTkVPS/PjjFPeHEo7j3jsM4D7lWmf4oFoaWnV9DivKCCRot/ 7jHZ6GSTVpTvIhbl3385IPpz03PMAqPXRpUrM= 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; bh=K0xlyMQ/dOYdblPn1aCAZbPODNQLh5ktdiFooUbCPzE=; b=rXJPOV8fAy5G5xfbhKLCTUVuwSzEfI1fB6RwP34PfP4ARJ/R4aJsTpYvbSUo7aRRYc LStUgyzozrY4b0B4dLkYjazYS9sJgvg6aWk0DE3zFRdumBn21/aOR6HLAsRf5GZVyjCs lfPWeAsTpK7exixkYAf4P7oPHm1wiz6EIG47Rg+gM+W08G9cdCIIpApQEGkcXGnmZZAv oOszgUm5KwJ5fVqQFvBR8BMKQkY9sjwduxRTQo6vMTVKGBiqOg7iKRMgHZG2mP0tkNb4 ic1ivTgxL3wUXxAE+slZemlRVfCcdbU1C1YNpN2dctut7eypIs3VpacDZMyRV419sEWQ 10lg== X-Gm-Message-State: AA+aEWZK5fanHj/CK1JhsoQ3CpHSROU2R3vBm7cqyVJmMnVRrOuxyK/H ugvmcqP9ySQMBx6xEZn4ghksHtv3cHQ= X-Received: by 2002:a54:4698:: with SMTP id k24mr10202927oic.37.1543869537071; Mon, 03 Dec 2018 12:38:57 -0800 (PST) Received: from cloudburst.twiddle.net (172.189-204-159.bestel.com.mx. [189.204.159.172]) by smtp.gmail.com with ESMTPSA id m133sm6330063oib.52.2018.12.03.12.38.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 12:38:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 3 Dec 2018 14:38:38 -0600 Message-Id: <20181203203839.757-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181203203839.757-1-richard.henderson@linaro.org> References: <20181203203839.757-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::242 Subject: [Qemu-devel] [PATCH v2 09/10] target/arm: Implement the ARMv8.1-HPD extension X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Since the TCR_*.HPD bits were RES0 in ARMv8.0, we can simply interpret the bits as if ARMv8.1-HPD is present without checking. We will need a slightly different check for hpd for aarch32. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu64.c | 1 + target/arm/helper.c | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) -- 2.17.2 diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index aac6283018..1d57be0c91 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -325,6 +325,7 @@ static void aarch64_max_initfn(Object *obj) cpu->isar.id_aa64pfr0 = t; t = cpu->isar.id_aa64mmfr1; + t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); cpu->isar.id_aa64mmfr1 = t; diff --git a/target/arm/helper.c b/target/arm/helper.c index a0ee1fbc5a..9bb3e364d4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9776,6 +9776,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, bool ttbr1_valid = true; uint64_t descaddrmask; bool aarch64 = arm_el_is_aa64(env, el); + bool hpd = false; /* TODO: * This code does not handle the different format TCR for VTCR_EL2. @@ -9890,6 +9891,13 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, if (tg == 2) { /* 16KB pages */ stride = 11; } + if (aarch64) { + if (el > 1) { + hpd = extract64(tcr->raw_tcr, 24, 1); + } else { + hpd = extract64(tcr->raw_tcr, 41, 1); + } + } } else { /* We should only be here if TTBR1 is valid */ assert(ttbr1_valid); @@ -9905,6 +9913,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, if (tg == 1) { /* 16KB pages */ stride = 11; } + if (aarch64) { + hpd = extract64(tcr->raw_tcr, 42, 1); + } } /* Here we should have set up all the parameters for the translation: @@ -9998,7 +10009,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, descaddr = descriptor & descaddrmask; if ((descriptor & 2) && (level < 3)) { - /* Table entry. The top five bits are attributes which may + /* Table entry. The top five bits are attributes which may * propagate down through lower levels of the table (and * which are all arranged so that 0 means "no effect", so * we can gather them up by ORing in the bits at each level). @@ -10023,15 +10034,17 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, break; } /* Merge in attributes from table descriptors */ - attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ - attrs |= extract32(tableattrs, 3, 1) << 5; /* APTable[1] => AP[2] */ + attrs |= nstable << 3; /* NS */ + if (hpd) { + /* HPD disables all the table attributes except NSTable. */ + break; + } + attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ /* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 * means "force PL1 access only", which means forcing AP[1] to 0. */ - if (extract32(tableattrs, 2, 1)) { - attrs &= ~(1 << 4); - } - attrs |= nstable << 3; /* NS */ + attrs &= ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] => AP[1] */ + attrs |= extract32(tableattrs, 3, 1) << 5; /* APT[1] => AP[2] */ break; } /* Here descaddr is the final physical address, and attributes