From patchwork Thu Nov 15 05:52:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 151170 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6594072ljp; Wed, 14 Nov 2018 21:53:16 -0800 (PST) X-Google-Smtp-Source: AJdET5f+2PkiPGdZ/4X+t2BlHBDsmnPkKHh53nMja9WljL4KRokAAMV1CZ3rZQ/9uU6WY3x4JL/h X-Received: by 2002:a17:902:7896:: with SMTP id q22mr4726229pll.280.1542261196620; Wed, 14 Nov 2018 21:53:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542261196; cv=none; d=google.com; s=arc-20160816; b=Az+adSqvYhAD4ySxieQpvSSVLI+IT8tuX/Ai+3kmuFHkJY02x9PRLttBLOKtqH5sYc QeDDCUZhx6cVHS+TvE8geLnL7/2lkOdtjjp0PnDjxPQ/X4jpU/r7ii1MlpeM5ovroPlK bJ4OfkQ7I0pqU4iKVUDUxtPmB3GZVWgb68vg2qzBNeSWUjjaTDMHm1jKXOvjnDsGgVLk 39oD2eP6row6A9/eF02Y07JNQmr2ez5cd7GAtSpDBzD7un34gBnYdVYinCqB5G5npwc5 jKIxOxiGmXpY/CtMi8LvM0VgMSqAcTD/ogp2SEhqi1t8lK79gwT/xlKqKZPUKxvLUcId r4vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=o5y8l0NsFtoWbp90IzL9nHnwXBQanitGUE7PDY2nFw0=; b=dWGmoLWTDlnQOBOD6sz2uIrdQFwAdGbSiFnPR8kUb+ymqo+9Q8LUdHd/D50YloTXOg jGhYu0oc1Hf4yXFzK5OQkjtHhlz2WhvMGXZlb2oRP6QWRqAaR2CJL/xdij+lpyM3HyB+ o7EVo5h9xBOoma0b0+ezPxCzT78hAFyZf9EWu9MRGGTMkX0UMMiOq5FEATpPGDjHS6z+ qmbqLePKfRE6NGKkpl/j4grCHKHVlQ3e3Z0/lWaLq0cMJA1ocrJGdUPpbnTAIznS8E9G 072zFmyaQs67H04L/qdpEoWN+cOMfTwXfZFRZHGMRq6XsuHQHqC+DN1ddOzJ4uBrlf1U obSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EtBHn+kv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5si6607505pga.352.2018.11.14.21.53.16; Wed, 14 Nov 2018 21:53:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EtBHn+kv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728913AbeKOP7j (ORCPT + 32 others); Thu, 15 Nov 2018 10:59:39 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:34949 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbeKOP7j (ORCPT ); Thu, 15 Nov 2018 10:59:39 -0500 Received: by mail-yw1-f68.google.com with SMTP id h32so2180615ywk.2 for ; Wed, 14 Nov 2018 21:53:13 -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=o5y8l0NsFtoWbp90IzL9nHnwXBQanitGUE7PDY2nFw0=; b=EtBHn+kvNnc+4EN2r0hbJOtGY9b+zYbzmZmiED+K8NRA7cYk1XfWnhksshiqQhgAEN ix8GpkWl+fDniCZKDfw1vzsSg0b78KRVJcHl2pWwVi1/5LbchSUTp73Er1LUijszQhf5 102zObBAKbKK1ewHXbJJ6C5kj4FiqqC/04haw= 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=o5y8l0NsFtoWbp90IzL9nHnwXBQanitGUE7PDY2nFw0=; b=hQlhwyOP9lZq3AWibCnvkoz2kF0PeoS1Km9mI6a43uBbTjSe4nrL9dMdlc5kFTlFJE fPVs18DgSzGwCYhVk084542pkbavkZEaW9VI6lriGeZyBryjf6dwy769OlXz05SzCKK2 E+7ErVA7AYXb+Kq0630DDnqetQQPyn8JBlWUwaM3iW3mPa2FTzvpw/5B+SGpZpvrr9ry ePqGWuqJNdoaRxEtx9vMz8a+v9jjiXqU4YgC0h0tdsSyxEGeiyK5DoLaAUMcOKkVR7hY ZkbofM531rfHv3bt3im/syfPVV+cVidac/0JtYj68DSLhba2INlkBboyqvA51SUeXmMZ qrlA== X-Gm-Message-State: AGRZ1gLl8Dja0K+XvoqO/m+zZurskkTIkVdjdgHh2iaF9OXCVAUFP+4r S2pv/F0dT0hJSQXVIp+2LXDytw== X-Received: by 2002:a81:5089:: with SMTP id e131mr1242482ywb.392.1542261193064; Wed, 14 Nov 2018 21:53:13 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 207-v6sm7417310ywo.87.2018.11.14.21.53.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 21:53:12 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Cc: prudo@linux.ibm.com, ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v16 08/16] arm64: cpufeature: add MMFR0 helper functions Date: Thu, 15 Nov 2018 14:52:47 +0900 Message-Id: <20181115055254.2812-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181115055254.2812-1-takahiro.akashi@linaro.org> References: <20181115055254.2812-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Those helper functions for MMFR0 register will be used later by kexec_file loader. Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: James Morse --- arch/arm64/include/asm/cpufeature.h | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) -- 2.19.0 diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 7e2ec64aa414..ef118d819fe8 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -486,11 +486,59 @@ static inline bool system_supports_32bit_el0(void) return cpus_have_const_cap(ARM64_HAS_32BIT_EL0); } +static inline bool system_supports_4kb_granule(void) +{ + u64 mmfr0; + u32 val; + + mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1); + val = cpuid_feature_extract_unsigned_field(mmfr0, + ID_AA64MMFR0_TGRAN4_SHIFT); + + return val == ID_AA64MMFR0_TGRAN4_SUPPORTED; +} + +static inline bool system_supports_64kb_granule(void) +{ + u64 mmfr0; + u32 val; + + mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1); + val = cpuid_feature_extract_unsigned_field(mmfr0, + ID_AA64MMFR0_TGRAN64_SHIFT); + + return val == ID_AA64MMFR0_TGRAN64_SUPPORTED; +} + +static inline bool system_supports_16kb_granule(void) +{ + u64 mmfr0; + u32 val; + + mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1); + val = cpuid_feature_extract_unsigned_field(mmfr0, + ID_AA64MMFR0_TGRAN16_SHIFT); + + return val == ID_AA64MMFR0_TGRAN16_SUPPORTED; +} + static inline bool system_supports_mixed_endian_el0(void) { return id_aa64mmfr0_mixed_endian_el0(read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1)); } +static inline bool system_supports_mixed_endian(void) +{ + u64 mmfr0; + u32 val; + + mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1); + val = cpuid_feature_extract_unsigned_field(mmfr0, + ID_AA64MMFR0_BIGENDEL_SHIFT); + + return val == 0x1; +} + static inline bool system_supports_fpsimd(void) { return !cpus_have_const_cap(ARM64_HAS_NO_FPSIMD);