From patchwork Tue Jul 24 06:57:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10541501 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E17B6184F for ; Tue, 24 Jul 2018 07:54:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3EFE2871A for ; Tue, 24 Jul 2018 07:54:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C78D628776; Tue, 24 Jul 2018 07:54:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 71F542871A for ; Tue, 24 Jul 2018 07:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=AH82xejSFq8HIgX/nWs4sY6xm75sFioCSxYC3DPXxNg=; b=qH/E2+sG97rzp1lY+V8j4bPz30 qS2OXeXO2sDLeLPRDx6sPlwMiE9b31WaZNkqCuNHqquZZzRxwqsR6pUvqODu8LIAF7ZE5WHLvK0Nl 1hl9nclU19Z5Va8u484wmQg0X2ivpuWNlVdUuJSwM/rdLCmHi2Zpb0bx4La4h/4ZcYxCExLaBSRgf 8BL/hjIXJI1Ob1YcTUZvnxadiSIfy34QcFqaFzTOLB1sZcBclhL1yxCGxg/JB1ErrsBlPAlJ4O834 YPbk/fZjGVGK/d7VOjH9nIYpwF34v1CxinJz/jpFM9iUuDs3zAhtPB0MkLBHF402623V5HDL3hA6j 7ddITf4Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhs90-0001UK-3X; Tue, 24 Jul 2018 07:54:06 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhs8F-0000PI-UG for linux-arm-kernel@bombadil.infradead.org; Tue, 24 Jul 2018 07:53:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4lNt0s5QqmaPUumDTmDh9tuGftffvBV/eRp5isuKW8Y=; b=dU65SCmUZ3bEmw10h/w/gVUby C4Eu3NIx5/Fk30kgmcpiAiqCmiYOlLFQ+QSKI8cmsV0YUc9X06MfxchLW+iACI4NseVibCshQMOYq gdExZWV74hSxBKkVy/reNqgXpGRvn2CzgloZ+7bGFI2UEAwF+MqdNStxj6YNs+7xGg7DmDhF/ZVRa fig3AQndHIcd9qN84cbqan4YxBvqOi7YjPjv4vQsFFAe6Krh/lL20Tjtfnrb64WK2Tr37lqCbO5kH D6w+Mc/pRqZVYDrBucnAqvUv5+RGQ/FxNNxH7/iU/UywKG9+v4iUGikzJSKUjthTYlNzpGanwoZVN 7s+q4+Uvg==; Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhrHA-0005cs-0F for linux-arm-kernel@lists.infradead.org; Tue, 24 Jul 2018 06:58:28 +0000 Received: by mail-pg1-x543.google.com with SMTP id f1-v6so2177861pgq.12 for ; Mon, 23 Jul 2018 23:58:20 -0700 (PDT) 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=4lNt0s5QqmaPUumDTmDh9tuGftffvBV/eRp5isuKW8Y=; b=IZCAvraVKXBMSrt+LprXRPa8TzsWBujFGzK9iGYEfcaNi9ch0BExwJB2bhWlPjxxw5 0RxjkbJ0RyPgwkU8AJzqEAb+Wilqoedt05oJtDRJAm0xODSkBfBlNNDzb6/9iqf2Xea6 ccl7Lfh3ELIhGGhvF4npOmcNsTPh8kJ81C+HI= 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=4lNt0s5QqmaPUumDTmDh9tuGftffvBV/eRp5isuKW8Y=; b=pEFBDe7ECK7DKrqsUL5VXOPPjl4pmY0I/QSAK1isCNV6tRog48pYoXCnu4hbJOGHwE oplsJsXnMPARtttsIeA7mAwwHxaWz1tx/ldTCjkXdYHqPvtAm0COxpHjz6cDowLp8L74 plCPwTtIdmUyGAD3q5hTfbUc8tDB8Y4/HOu9y69Uh3SnhuJXNo9A7oCuSr21AJAvy0Xa GqbMidMsX9jTDBsXKU3OBIjJH0uLZofU7+MAySJhw4+Op5bbpQwVscAJMxOeCbvXqHMi ZMEx4cA1LuAzkdvQYIcEkAMtnY8pyM+/sA0D4nKeKFziM/AgsUvmEG/lsV4s7WFID9ee Ywcg== X-Gm-Message-State: AOUpUlEnYMXtqM5GNAd4fRcPMpMKnT76itMXatzqgJEUwuL8vQAJD0yp JYeaQZw22Evq2ERa/4Mts0muIQ== X-Google-Smtp-Source: AAOMgpeTka3r2VkaE8A4nOw6byWcsgyhZRfyzVMrHXe+TqVMyReY7+zdj63kRyqCRVdniZFbYXO3SQ== X-Received: by 2002:a62:c0a:: with SMTP id u10-v6mr16375735pfi.43.1532415498607; Mon, 23 Jul 2018 23:58:18 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id r19-v6sm15966732pgo.68.2018.07.23.23.58.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 23:58:18 -0700 (PDT) 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 Subject: [PATCH v12 08/16] arm64: cpufeature: add MMFR0 helper functions Date: Tue, 24 Jul 2018 15:57:51 +0900 Message-Id: <20180724065759.19186-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180724065759.19186-1-takahiro.akashi@linaro.org> References: <20180724065759.19186-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180724_025828_179169_1F92C048 X-CRM114-Status: GOOD ( 13.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ard.biesheuvel@linaro.org, bhsharma@redhat.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro , james.morse@arm.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 1717ba1db35d..cd90b5252d6d 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);