From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEDE23FBEA2 for ; Tue, 24 Mar 2026 14:09:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774361399; cv=none; b=nl07wm+3tbQFlsv4PAXsT5uzKjsPkxS5K5pZO6JnMVmww8wO0ShqOqRESo83XR5gW34E4ppNFLXkEi8/JU8+SeDH3gglHSAMLiVwyfpo7FCc8PfnPOB7Hg4Qaqi9Z6lCiKsR6TtWxmUHIS5Lw2u5YvybrNnhRdQa+fhizH6TFLA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774361399; c=relaxed/simple; bh=4+y5I6IOKnlryBOWxlKFSero7k0psB62OJhw3COE4yc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MRU6oPELbwNi0hOCTH8g+sarIwH3kwr4oGn19PvlJ9EZQv3ohPbUHLcuYUB9vOvHq/hFKg6GIZHEnsVUUj9rUVDhlxp1Y2/pl1DObpHMaZ9H83grWmVU/xPRJAzoAYGZEaSgXRSGQYOY1V9XPyrQ6G05c8sFb37QkLIK+tJi5TY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NCLKuWFM; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NCLKuWFM" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-482f454be5bso59449475e9.0 for ; Tue, 24 Mar 2026 07:09:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774361395; x=1774966195; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tZ4LSksyFg1Xo3cRrPoFB7zz76+M0JIYSoezHnjgfsE=; b=NCLKuWFMTyYV4TTquedyaCokOAY3CajURHGE54k+so9XfPXvDXztYrae2LJZm2Ae0I YPNzSlYgU7vrwQqaFP62LEh7/Lr+bAK8TR22fdXNz0pP42TR+w9jqKtCr3xEEmdCXY+i HWnSvZgU58KYdFHnqmwnadW1fQy3Nw5oyfWMzzTXqgQlkfZUidYJwjstY26uViY0aqAH 41pX1N8YeUG+bt6n2H2NxV1lGLTbsHeUcjagLbBjKyW76vB7DkQPGc0XNAFx4715Y4zg LeXtvhleaTLEULH9aRctLs2EpCy8Cc5D7qrVRMCdpA2CbNEEloaeJXOCGEOdhmkDlUpO EUNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774361395; x=1774966195; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tZ4LSksyFg1Xo3cRrPoFB7zz76+M0JIYSoezHnjgfsE=; b=IVi9xxjfx2pdGcbHazt8jVgQjg3JCUJmHiviD4HwrkAgh/lvzyoSdbk/6+7OV5xb4u 9NKYp5/NbkfJCMlXI/c1o4+iiedb+AC+YWfWAU3eRK2qmqKY0tuvRovcRmKm1YKHjHNt bD9tFQFO3XQ4dPKwObAFgY5PlsC82wFHM63ZYfFfUo5UPssWWEFVB1YHWRt/xXSlgUu2 IIWLteUBGzRuqhw2zDawRA4+nfhL6ash0pm+yxi+OUCa2owscHlQqOwitEO2xaKvimTH 8ysgKJC2oEyHfDjGL67mX7e/CcXpfa08GQRSNO3988Kq3URZddqHhyB0ospiBpJj9PMM qEJg== X-Forwarded-Encrypted: i=1; AJvYcCVWdUI0kLufAyixFmwWzpW2+38wFRlCMKNqWHQHsyiFtt7iNU6wscD62Gxf9yNrZujp1+6il3ZxhqTY+90=@vger.kernel.org X-Gm-Message-State: AOJu0YzDtQVSElDvDctWMIXVQsuix5Z6vYficeoqalTZOJaXPyc61pGH A/SnhehhSPEPVe+gVYyGPC/iAzdNpFPSv0ts3zqs9sRd6Z4nS8pevX1BlAT5tUvjSA== X-Gm-Gg: ATEYQzzPVFm0ycUG+/zL14TYw7ze+Lw7J74jfJ5XNe9VNDcNZsvU1tSdW7r2xJtIEo7 i0Whb5zW2xZwHN9ApNZubbsbRrUAv5ZgJglpoYhuQX1uayFlETwnxjweF9fWuPkXfGgiFqxDJVT wtYtTq2hGpg9n7npgQyu7RpS1t5cdUhGfYMiZvpDHAINSn2IJfywR+SDcbcbbZ+ZsSeYSOCpmOx /4pUkauowWklZmdx9y42ejGp1VxfJP3kakBJsQOvHA03yPUJvOqvu7ZfNcd3V1A9g3ASjjwZcOv Fw8LNIO7xMjOTMUoMwv/f5KFLLDgpap+6EJUPjpGUFcUfrtyJDwYVCvgzpni3DhLknwxzDZyxF0 tv8tfq9xq6v61Zv9lgBy1USGzB/cILe4tewVw8/Ku3/rtrBF0cD2wfPBv7MYMxRvtuvKyD/oE5S 4YHGdgw43M24ti8D6uK67pg8XKBVZtJUECWeaUSiNlBWCk3Rtk+WRLQjLOqJRqigD2Smo= X-Received: by 2002:a05:600c:1d02:b0:487:12c:e7ea with SMTP id 5b1f17b1804b1-4870f1f40f8mr51547485e9.5.1774361394440; Tue, 24 Mar 2026 07:09:54 -0700 (PDT) Received: from google.com (198.115.140.34.bc.googleusercontent.com. [34.140.115.198]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4871105c799sm24855475e9.20.2026.03.24.07.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 07:09:53 -0700 (PDT) Date: Tue, 24 Mar 2026 14:09:50 +0000 From: Vincent Donnefort To: Sebastian Ene Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, android-kvm@google.com, catalin.marinas@arm.com, joey.gouly@arm.com, mark.rutland@arm.com, maz@kernel.org, oupton@kernel.org, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, yuzenghui@huawei.com Subject: Re: [PATCH] KVM: arm64: Inject UNDEF when host is executing an smc with imm16 != 0 Message-ID: References: <20260324135728.3532400-1-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Mar 24, 2026 at 02:06:40PM +0000, Vincent Donnefort wrote: > On Tue, Mar 24, 2026 at 01:57:28PM +0000, Sebastian Ene wrote: > > The ARM Service Calling Convention (SMCCC) specifies that the function > > identifier and parameters should be passed in registers, leaving the > > 16-bit immediate field of the SMC instruction un-handled. > > Currently, our pKVM handler ignores the immediate value, which could lead > > to non-compliant software relying on implementation-defined behavior. > > Enforce the host kernel running under pKVM to use an immediate value > > of 0 by decoding the ISS from the ESR_EL2 and inject an undefined > > instruction exception back to the caller. > > > > Signed-off-by: Sebastian Ene > > --- > > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c > > index e7790097db93..ff6a90a4a4c7 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c > > +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c > > @@ -756,13 +756,18 @@ static bool handle_host_mte(u64 esr) > > void handle_trap(struct kvm_cpu_context *host_ctxt) > > { > > u64 esr = read_sysreg_el2(SYS_ESR); > > + u16 imm16; > > > > switch (ESR_ELx_EC(esr)) { > > case ESR_ELx_EC_HVC64: > > handle_host_hcall(host_ctxt); > > break; > > case ESR_ELx_EC_SMC64: > > - handle_host_smc(host_ctxt); > > + imm16 = esr & U16_MAX; > > + if (!imm16) > > if (ESR_ELx_xVC_IMM_MASK(esr)) ? > > Also, I can't find void inject_undef64(void); I think you need a vcpu for that? Ah my bad, handle_host_mte() introduced it! > > > + handle_host_smc(host_ctxt); > > + else > > + inject_undef64(); > > break; > > case ESR_ELx_EC_IABT_LOW: > > case ESR_ELx_EC_DABT_LOW: > > -- > > 2.53.0.983.g0bb29b3bc5-goog > >