From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C84B623; Thu, 14 Mar 2024 22:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710456050; cv=none; b=HmMRRsE7Xy4XYxDARgaJhsUTnFtTIc+sRK5+kyJDykrm0LKEWhDTuCog3clV8X2PJ7cPwtxO2dvD6Hjo3O+Irhf7apYdDyjP1xQ43e7AxaSxOaeb7hIigsPUBC3Na1JJ8zyb6UyvXq5zU9MFeOx0CQqirJieRogNnY+Wy1PVSm4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710456050; c=relaxed/simple; bh=IJPqVtR8QSM/d1Gfah9hBxpHWVHr3H8lUxgZ+S0EhzA=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=ZUd933BZiZ018wc0FmKsL9Db7FXracm6Cz1lgzIbFNkxSaCzHDuAU2CDY2BfN0/+mZWakWNazQX914ChBqYK8ZBsvnnut+l04zIKHzhvc2DqWJVXuZa0/MF5fnx6NDSCIbbICYvmmH4fj3XTjI20Vp2tub2Zr8VQY5mnx9+YRUI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RJi/YQ1C; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RJi/YQ1C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 208D3C433F1; Thu, 14 Mar 2024 22:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710456050; bh=IJPqVtR8QSM/d1Gfah9hBxpHWVHr3H8lUxgZ+S0EhzA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RJi/YQ1C6bMovlwymdVGTi5vND+ai9juEP5OI0xr6YimWdI9+4gWZnreAhrV0SwEr ES1tLHh6gGA5m14fQug4hxWqk2m6FLJB+aoFUZp9KpmvmUfm9wmAI1lWiJpSvs67I3 H9eSw0EYg0wQPRTHmvr3MzScpDBhWIcVQsR8bXfsXIIA0R4U49zGwrb5A2uv/FfEYq SAWZht/LWwUay0vjmyc3+30qCWoTqs1uY5zC2KsD9L/F/iZL00YZBp9FgoUIUlcHDw B/wUfvZnqVI0yiqcWMm8TATrI3zrMIc+ZslB2IVdP3KlWsBGpr8o4vyFc0W9pdt9mC FtoeUxDFAyJGQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rktkl-00CWD8-O5; Thu, 14 Mar 2024 22:40:47 +0000 Date: Thu, 14 Mar 2024 22:40:47 +0000 Message-ID: <86edcc1low.wl-maz@kernel.org> From: Marc Zyngier To: =?UTF-8?B?UGllcnJlLUNsw6ltZW50?= Tosi Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Sami Tolvanen , Mark Rutland Subject: Re: [PATCH 00/10] KVM: arm64: Add support for hypervisor kCFI In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: ptosi@google.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, samitolvanen@google.com, mark.rutland@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Hi Pierre-Cl=C3=A9ment, On Thu, 14 Mar 2024 20:23:00 +0000, Pierre-Cl=C3=A9ment Tosi wrote: >=20 > CONFIG_CFI_CLANG ("kernel Control Flow Integrity") makes the compiler inj= ect > runtime type checks before any indirect function call. On AArch64, it gen= erates > a BRK instruction to be executed on type mismatch and encodes the indices= of the > registers holding the branch target and expected type in the immediate of= the > instruction. As a result, a synchronous exception gets triggered on kCFI = failure > and the fault handler can retrieve the immediate (and indices) from ESR_E= Lx. >=20 > This feature has been supported at EL1 ("host") since it was introduced by > b26e484b8bb3 ("arm64: Add CFI error handling"), where cfi_handler() decod= es > ESR_EL1, giving informative panic messages such as >=20 > [ 21.885179] CFI failure at lkdtm_indirect_call+0x2c/0x44 [lkdtm] > (target: lkdtm_increment_int+0x0/0x1c [lkdtm]; expected type: 0x7e0c52a) > [ 21.886593] Internal error: Oops - CFI: 0 [#1] PREEMPT SMP >=20 > However, it is not or only partially supported at EL2: in nVHE (or pKVM), > CONFIG_CFI_CLANG gets filtered out at build time, preventing the compiler= from > injecting the checks. In VHE (or hVHE), EL2 code gets compiled with the c= hecks Are you sure about hVHE? hVHE is essentially the nVHE object running with a slightly different HCR_EL2 configuration. So if you don't have the checks in the nVHE code, you don't have them for hVHE either. Or am I missing something obvious? Thanks, M. --=20 Without deviation from the norm, progress is not possible.