From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 AF5003FE35C for ; Tue, 24 Mar 2026 14:42:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774363324; cv=none; b=YAYgRMpvuo5eI9nFthji4S0dWz0I211I2kqa531AOzZkgmV0J6mVgNNWCWfVMljWQZydnO7ks6m6ykpuRVgDVq7oYLHDdq0SEBiGCwEKuY/dR5hSu4UOtA/QebIXWgBQ9Jv1xdmbiXhomz3UmbH8NPpodPjHcyNl6J5wEVZGZKM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774363324; c=relaxed/simple; bh=E4zjjo8iv0G1bhz4bnn2Tfxy9XKsaj1cvPVt39yIrQg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gb7aqUihUDYDDlwhfYa0qKQgiwDqnyW/kDjQHsaXfC2OfK7H/S+XjYppuswDYXzv0Yi04cHCPWD863vlOVwjg6NN7GTapicNVEp10DCAaKDPdzZHwVLah03RCObCja8106+J/uMg3HahBfxFyRGW6Dcyexq5Tko6gPLELleB0+c= 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=cXTAdHyO; arc=none smtp.client-ip=209.85.128.45 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="cXTAdHyO" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-485317b6bd0so62345e9.1 for ; Tue, 24 Mar 2026 07:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774363321; x=1774968121; 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=R9azy4441Z9htuSU+O0vgMgPqnPm0TMDTgfr4iB1vDg=; b=cXTAdHyOwmUJyg0s9p728X8tLPCTNmJOHwJq9OHUGnLZcaesw/qGCabjhYvcn+6SdU p2RqVF4Gqm3WTfH3Nzv7Z9M3TjAIyZsAhLJg5XhKD0RJZpFxqGsXmcfhKxedJrlfbZIr FXh8LbYqTRJgCCheWa/2MkaXVo0Kw+0LoyRYWTtizdQ7ylj8zjHRpF4rHQBg6vGv2EWB eNHRoVDTWXUaLusGmStFK34Lrt0QIdsFu08b4xC6WmvIpJ50R7xXTABWvByIPgOWI1At 6DzyH2kQGoJ7ep9lK4Sd0NoEYetbpuSaZXSfZJbAzH7eDO7AlwZMLwfKp5qwzbDKBRPQ uXjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774363321; x=1774968121; 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=R9azy4441Z9htuSU+O0vgMgPqnPm0TMDTgfr4iB1vDg=; b=D1yERwaBnkYP1goLYO8kGi9HSSm93ZvoVoH0GukL22N9rBPs93loFBRiWQ64ZFE3d9 l9Pk24p5FFtQQy6GY8LYloHTDTfozp8SiGJ+O03413+8L0fVXAwFYG3W5uXMIakJeI8x 6veSEtTrKUMkLZuDlWqvq3E6sscuRNdi+0v4IaV095Dj96xk131HGSjRHcECKbY6ziMq j5nv2pxld+IUtkTb30HVwWaEBGwf26jrukO52Wc0tO7IkQkZ5/mP1i1IVzc6TZWloH7O 7xMp6U4a9xQuqDYre9+zlIELfOB+EBIq805+vN4xopVacQ2NkvDrF/WaDeERXmpjM6C4 Pa8Q== X-Forwarded-Encrypted: i=1; AJvYcCXBlDpbkfYLIhLGNd5pS3V/Xl5pDChPZ8yLqjJ//AfQ/0U64lFJPZMHJ0xJM7fi5srdNieBHemnyBim+q8=@vger.kernel.org X-Gm-Message-State: AOJu0Ywzyn8uE0rEOV/3vu45IiGUiqQEsOJyF3WKELtvKphH0O7O9ful Sb9b/OMSoJpEZeqSSQI7xkQftH9EcPZj10Bo4IwSclBIfJeSvf/WiyyU2YJbuJQAKQ== X-Gm-Gg: ATEYQzxi+LGHuaP971fLxPlP2M4JGFaJPHYCOmaJyjJqK9z3mJdAbiqXONs+raBa0/f HJBejapOeFJ2EFA7MaHbPE6ayiaJfB5PSGNu3DcqvLvaPM18Qns/sEAA+suyrA2SC/QdLuVzea0 BruvMDIz210tqe3amhmjyGPNjOez/7I/hcsjSbg6560P7J/M7IHyG5gNrz1ZbSq9yZkcpSK7y+1 Li6EdQwiAN2cu/zNAWr538Ad621m5HkaggBlSMh80Pzgb+05FCaos0GOkEqJPx7iaxhXdxd2tx+ jOqXvtj07nM+1BCDM/UbwHwdrf3eMbeHRGBjofioYqq3BwzjkwZTsYValP7Q8msDgLqGfYHx9Y/ XPz+fW7/t77ZTzDQGqw7Sj6H7iLm43P5UjU1mu9b3Xp9LlcsGqRdrIJt/3+ZCW/wGH97ScSkj5j WCG5ItjBG8qzsBVFkdEipw9HA6Ml86pOl66RYYx2fiU5ODgOmVct8UdhF9+Ds2YVjCk4o//3Vs4 YqIFw== X-Received: by 2002:a05:600c:4e0e:b0:486:fbd9:b22c with SMTP id 5b1f17b1804b1-4870f59993dmr1066435e9.16.1774363320437; Tue, 24 Mar 2026 07:42:00 -0700 (PDT) Received: from google.com (209.13.205.35.bc.googleusercontent.com. [35.205.13.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b64711f58sm39757790f8f.29.2026.03.24.07.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 07:41:59 -0700 (PDT) Date: Tue, 24 Mar 2026 14:41:56 +0000 From: Sebastian Ene To: Vincent Donnefort 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) > Hi Vincent, > if (ESR_ELx_xVC_IMM_MASK(esr)) ? Yes we can use this instead. > > Also, I can't find void inject_undef64(void); I think you need a vcpu for that? > Right, there is one version that does that. > > + 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 > > Thanks, Sebastian