From patchwork Thu Dec 6 22:50:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 10717155 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 3E23418B8 for ; Thu, 6 Dec 2018 22:51:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2305D2F137 for ; Thu, 6 Dec 2018 22:51:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EE792F27C; Thu, 6 Dec 2018 22:51:23 +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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB1352F158 for ; Thu, 6 Dec 2018 22:51:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC2656B7CCE; Thu, 6 Dec 2018 17:51:12 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A6E336B7CCF; Thu, 6 Dec 2018 17:51:12 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9145D6B7CD0; Thu, 6 Dec 2018 17:51:12 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by kanga.kvack.org (Postfix) with ESMTP id 5B0B96B7CCE for ; Thu, 6 Dec 2018 17:51:12 -0500 (EST) Received: by mail-oi1-f198.google.com with SMTP id p131so973107oig.10 for ; Thu, 06 Dec 2018 14:51:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yzRkPlJ6Xb4mCkVTu6FisV1UWzBQMblp8GtIYTafloc=; b=XLUlKeTf7c3xp5UtBS10z/NXLQQSQz7S8qOC/Os0X7JnYhDIyCndn1ptMxyYX2RvdT tTXxhuWrx1X2WnqtgxURoy7+EMrE3dw7rc3t4azlGyDyzL5qd3UBA7m3wuO2yTcuuSWS fo6+8u6lYQf1g/snlgb4bjrOY8w/zXXujzFpnELU6aMMTSL0xLrvcARqNrkH+PBs8LY2 VQ8u5U3t+vv+PYDPJQIP6CftJdOAMqxmDCVtDkkh46yqmW/63SGGFjt0kTvrAJxdkZC5 ILsdULrEf223ToJsRiNKsw8pJJjlR4EtVj6TLpQqgRUqMFfdXK2iNMsiQJJ9rkj805Qe ucJQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of steve.capper@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steve.capper@arm.com X-Gm-Message-State: AA+aEWbYa7wYNSDFEfUTg1BuLdreKz1DKayGmsYLRC/QY+Rlg81xShb/ BfChvz3m0vclxGGIQjzw+ISiumrHx/Weth7RboK2hRR/XVuxIwlFadncFAn4Ro9PAkfjOfHA79I W0uQiAsgBDG7uToJBi1WQrwZQeKvWHjSFFIzptUsNSddJLjau0KJKzXDtAs1UTy4biw== X-Received: by 2002:a9d:7a8c:: with SMTP id l12mr19890906otn.335.1544136672132; Thu, 06 Dec 2018 14:51:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/W9RH83JNrmsz6gBBT7/rbShXoj/AN+UzkrrEqI0xMLVWJYPl4y9WW61kOC8Q4ttQqKVFOt X-Received: by 2002:a9d:7a8c:: with SMTP id l12mr19890881otn.335.1544136671275; Thu, 06 Dec 2018 14:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544136671; cv=none; d=google.com; s=arc-20160816; b=C0SWIPnIgK63LnVhMYcpZUXg481X3bcyUda8xH4ZfoNfMGmRCIYaSf4vnsx7kIETZr hfum/jc8zIMpuA29laCcPnbrw/VcxJnygjfU07F4wvOWiRCo2gQpGEkT1qnQDHIv6FCR WGm5uMJ2GG+Vpube2fKzEwwGL3CC/fhTBOGvJEkIYDtE5s8eXBt9YP601GchMLLoR+xt zb57KR47+gHRXurYsYnE0NMkCPoX9OjhNHC44ff2HRX3532wxfXveFgybuOQ8ae7aPyY r1TBsXIrRqp1Wp8SIChdvSArdPkgWH1OwRxBPg3uVDI3AKHeE9lPSvqFwuV9hQcmXVxw B87g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=yzRkPlJ6Xb4mCkVTu6FisV1UWzBQMblp8GtIYTafloc=; b=z/lE/W5uU7oRmXXd6syAz+w9BF7d4KFGYvHCiBtXc5XdtMQM4yPtlHYG3/78/KcpsI TeqZWAkDBEIGyQflcAFnxyrmYKyaKa4m6LSMmZxw8u6qdo0qXGGw8WkZFDMsUsY6F+W3 Ku1eyjRhlZt1HT1UC2zA1SrziVgOHNXAXnE/eHnpI6mUChGAXboLRm33CcS7aiu1Vg5t YZKzv5Q6hy1sRS7pbg+FdYF6QuIJpyo3MGNexyzCw5FQ7oHwK17W72N/AhCwwagYgL5D JbwsXrxbcOKReutTnj0dQGuKEFGb1RHcwRcBZRWi2Gy3kc08nfS1F5feMpQ1hd6G5kjY Rqmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of steve.capper@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steve.capper@arm.com Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id r17si688844otk.179.2018.12.06.14.51.11 for ; Thu, 06 Dec 2018 14:51:11 -0800 (PST) Received-SPF: pass (google.com: domain of steve.capper@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of steve.capper@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=steve.capper@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ACB561596; Thu, 6 Dec 2018 14:51:10 -0800 (PST) Received: from capper-debian.arm.com (unknown [10.37.12.92]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 294D83F5AF; Thu, 6 Dec 2018 14:51:09 -0800 (PST) From: Steve Capper To: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, ard.biesheuvel@linaro.org, suzuki.poulose@arm.com, jcm@redhat.com, Steve Capper Subject: [PATCH V5 5/7] arm64: mm: Prevent mismatched 52-bit VA support Date: Thu, 6 Dec 2018 22:50:40 +0000 Message-Id: <20181206225042.11548-6-steve.capper@arm.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206225042.11548-1-steve.capper@arm.com> References: <20181206225042.11548-1-steve.capper@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP For cases where there is a mismatch in ARMv8.2-LVA support between CPUs we have to be careful in allowing secondary CPUs to boot if 52-bit virtual addresses have already been enabled on the boot CPU. This patch adds code to the secondary startup path. If the boot CPU has enabled 52-bit VAs then ID_AA64MMFR2_EL1 is checked to see if the secondary can also enable 52-bit support. If not, the secondary is prevented from booting and an error message is displayed indicating why. Technically this patch could be implemented using the cpufeature code when considering 52-bit userspace support. However, we employ low level checks here as the cpufeature code won't be able to run if we have mismatched 52-bit kernel va support. Signed-off-by: Steve Capper Tested-by: Steve Capper Reported-by: Steve Capper Signed-off-by: Suzuki K Poulose --- Patch is new in V5 of the series --- arch/arm64/kernel/head.S | 26 ++++++++++++++++++++++++++ arch/arm64/kernel/smp.c | 5 +++++ 2 files changed, 31 insertions(+) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index f60081be9a1b..58fcc1edd852 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -707,6 +707,7 @@ secondary_startup: /* * Common entry point for secondary CPUs. */ + bl __cpu_secondary_check52bitva bl __cpu_setup // initialise processor adrp x1, swapper_pg_dir bl __enable_mmu @@ -785,6 +786,31 @@ ENTRY(__enable_mmu) ret ENDPROC(__enable_mmu) +ENTRY(__cpu_secondary_check52bitva) +#ifdef CONFIG_ARM64_52BIT_VA + ldr_l x0, vabits_user + cmp x0, #52 + b.ne 2f + + mrs_s x0, SYS_ID_AA64MMFR2_EL1 + and x0, x0, #(0xf << ID_AA64MMFR2_LVA_SHIFT) + cbnz x0, 2f + + adr_l x0, va52mismatch + mov w1, #1 + strb w1, [x0] + dmb sy + dc ivac, x0 // Invalidate potentially stale cache line + + update_early_cpu_boot_status CPU_STUCK_IN_KERNEL, x0, x1 +1: wfe + wfi + b 1b + +#endif +2: ret +ENDPROC(__cpu_secondary_check52bitva) + __no_granule_support: /* Indicate that this CPU can't boot and is stuck in the kernel */ update_early_cpu_boot_status CPU_STUCK_IN_KERNEL, x1, x2 diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 96b8f2f51ab2..e15b0b64d4d0 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -108,6 +108,7 @@ static int boot_secondary(unsigned int cpu, struct task_struct *idle) } static DECLARE_COMPLETION(cpu_running); +bool va52mismatch __ro_after_init; int __cpu_up(unsigned int cpu, struct task_struct *idle) { @@ -137,6 +138,10 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle) if (!cpu_online(cpu)) { pr_crit("CPU%u: failed to come online\n", cpu); + + if (IS_ENABLED(CONFIG_ARM64_52BIT_VA) && va52mismatch) + pr_crit("CPU%u: does not support 52-bit VAs\n", cpu); + ret = -EIO; } } else {