From patchwork Thu Oct 8 18:16:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 11824305 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D2D61592 for ; Thu, 8 Oct 2020 18:18:39 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4DA2222200 for ; Thu, 8 Oct 2020 18:18:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QK9+n8jB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DA2222200 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id: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:In-Reply-To:References:List-Owner; bh=APIHkYW8juhXUMLWwlcmdKL9mg+045+3ag47r4e3ViU=; b=QK9+n8jBS6dJXMrldGbHN7alpO 8t1/TreXCMHrPgFzqnFXrMm8RC/3tS580rr8wpCTZGJgjOl2HcAfft6jCTlK87mjEHliv61payZTD 2MDCIuhu9OiTiPjwb7Pbt1mp7TQSaxhrP3b8he7rxEEU4JS5nv35rMIriaGnS0rRa+073I2zN9TVF St8e4RehBLPVomZFSuJ1cQgEBqlDpQf69os6LYmazi7GUf4tCQ0/HwicBRdelsJeJIKny+pY5+G06 HcUR4mfstUZ27NNPHEnQBqS3+6IlvjjI0+mzyFdFrFRPLI3oIJBGqMjI+wXu6vOUmBACVRPVvxTgk v3TRAEJA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQaTK-0004aR-Gp; Thu, 08 Oct 2020 18:16:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQaTI-0004Zg-Q8 for linux-arm-kernel@lists.infradead.org; Thu, 08 Oct 2020 18:16:57 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 497F8D6E; Thu, 8 Oct 2020 11:16:52 -0700 (PDT) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ED9113F802; Thu, 8 Oct 2020 11:16:50 -0700 (PDT) From: Qais Yousef To: Catalin Marinas , Will Deacon , Marc Zyngier , "Peter Zijlstra (Intel)" Subject: [RFC PATCH 0/3] Add support for Asymmetric AArch32 systems Date: Thu, 8 Oct 2020 19:16:38 +0100 Message-Id: <20201008181641.32767-1-qais.yousef@arm.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201008_141656_895460_2BDD323F X-CRM114-Status: GOOD ( 15.12 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Greg Kroah-Hartman , Qais Yousef , Linus Torvalds , Morten Rasmussen , 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 This RFC series enables AArch32 EL0 support on systems where only a subset of CPUs implement it. AArch32 feature asymmetry comes with downsides, but it is likely that some vendors are willing to accept those to maintain AArch32 EL0 support on systems where some cores are AArch64 only. Enabling AArch32 when it isn't supported on all CPUs inevitably requires careful affinity management of AArch32 tasks. The bare minimum kernel support is offered by the second patch which put the burden of managing task affinity entirely on user-space. AAarch32 tasks receive SIGKILL if they try to run on a non-AArch32 CPU. The third patch is optional and overrides task affinity in some cases to prevent AArch32 tasks getting SIGKILL. We don't expose the asymmetry to userspace. If we want to delegate affinity management to user space we need to introduce a way to do that. /sys/devices/system/cpu/cpu*/regs/identification/midr_el1 contains the specific CPU ID. This could be extended to expose the other ID_* registers where the AArch32 feature can be detected. If the user hotplugs all 32bit capable CPUs, then all running 32bit tasks will be SIGKILLed if scheduled. Patch 1 ensures KVM handles such systems properly. Especially if the guest is misbehaving and tries to force run aarch32 regardless of what ID registers advertise. Patch 2 introduces basic asymetric aarch32 support. It will SIGKILL any task as soon as it scheduled on the wrong CPU even if its affinity allows it to migrate to a capable CPU. Patch 3 suggests how handling the affinity problem could be done in the kernel. It's not a generic solution, rather a demonstration of what could potentially be done. Qais Yousef (3): arm64: kvm: Handle Asymmetric AArch32 systems arm64: Add support for asymmetric AArch32 EL0 configurations arm64: Handle AArch32 tasks running on non AArch32 cpu arch/arm64/Kconfig | 14 +++++ arch/arm64/include/asm/cpu.h | 2 + arch/arm64/include/asm/cpucaps.h | 3 +- arch/arm64/include/asm/cpufeature.h | 22 +++++++- arch/arm64/include/asm/thread_info.h | 5 +- arch/arm64/kernel/cpufeature.c | 77 ++++++++++++++++++---------- arch/arm64/kernel/cpuinfo.c | 71 +++++++++++++++---------- arch/arm64/kernel/process.c | 17 ++++++ arch/arm64/kernel/signal.c | 33 ++++++++++++ arch/arm64/kvm/arm.c | 17 ++++++ arch/arm64/kvm/guest.c | 2 +- arch/arm64/kvm/sys_regs.c | 14 ++++- 12 files changed, 218 insertions(+), 59 deletions(-)