From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 D06F8405AC5 for ; Tue, 24 Mar 2026 15:05:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774364743; cv=none; b=g3hMzqARFIFzTz+g2icOv4/yb9uxvs+vGcimkHLdyejSF0tlocF7NfIjTU5jMKwvrb+cmvI/bmSQm6jzK6mcBZtuYl/YJd1yAh3K8ExoGRD99UScuQlNd8jHqCduU9JucAR3KPCeMQzUW62brQCy+0BfhheyNu3N5krZ44qwYlA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774364743; c=relaxed/simple; bh=O8P+TZRrxrEvgVcIPzX4mQiT9SPX7cc192URaBSZUAg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cI/XU3xYjK2IzHrs1uxvxt36uzS4mb3csMQZ5mGiaj9PFRFRC/Y0ri3/LH3e7izb+yD+2Sa5ztTQ7mpXWWBTqlaBaK03NjiHzpYrQHsyMhsisGjpnkstKhwwBZIBZxYZCWU+B0D4ISeA+EPdtyt0gi/pfh6+m+BgZ5CWUcD5QiE= 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=U7svVDGf; arc=none smtp.client-ip=209.85.128.52 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="U7svVDGf" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-486fb990b9eso78785e9.0 for ; Tue, 24 Mar 2026 08:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774364739; x=1774969539; 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=ptGMB7I5UZgWyMFfPZCZTiz7S0WJEUd1UA28PK4qTlU=; b=U7svVDGfvySC7XW3sMBsMpaD8+f90zXpnuPAOiwt8zJ0pwX0UdR9PUeadidL8aZ4V+ Dx2lp2IqjXBfYgCYhI6AkdvgkrU7yHWfFn5L084bZRkyuIqS6VbW0fgPB7ICrxQH+ptW ePDQdNm2yrP8m1YrsJ6rHt/MzCg0sQKH73QNURZ2kS8FwNskf458evcYpcFWY5BfVLkp BgN7UEWbfaECa/n+QPyRlCULtNMO+wRObRQbojtnlsYiAqc2opDBb03SxhcXsC6U5wKJ 7eN50NZOdgHIP0kfx/v6Nvcje3Ebm/H5pfbaJ2bk93Jr2x9i2YhGwxqpxtdDGGQNSxqN sS6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774364739; x=1774969539; 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=ptGMB7I5UZgWyMFfPZCZTiz7S0WJEUd1UA28PK4qTlU=; b=Htj076dJhvPDYFn7R8NNII60++pD7vHG1FJurM0Rc9f2Diz9PH4tADFWvyXEdaulCG i89Umf6dKpGPSOPou9G8T0Ey+4VJ12GNi/Aaa52e+i3dC9unNTu9vB5F4NsXxoH58Le2 JsDEdk6tNdaX23pFjj0gxN8k2dZ76i1WuO+pQiBiqZASqzO5C/eiS5PP4A7lapQKqOtY oj8fpl7kfH64ZYy+e3blm/60Od8JHLB54sUd1NtugJfPhDm6q70lHJEOdZG7u9clds6e 37Txck/xWzJUvMqFjdIlUGVHndN8wiWgpUMw3Ngo8BAftCicz/YhCP1douC50A+9SI3n /+qA== X-Forwarded-Encrypted: i=1; AJvYcCVEOyIICZlT6Cp9OlnYJCJV+UGozrLE21XMdaINfxiKVN07kns6am8TlPSHgyPXqm4+5bGd5fEjfIaad3Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5/mpKahP1AtiIzxRZCcBd8MvC+1BeBkKZdXqt2XXM8UWMSE3+ SupXk5ZSW4ieGa/XDd4rVo2btZMvTJlvK/N1VjzASR9u5fY9D2tqw5hRbcchKhLoqw== X-Gm-Gg: ATEYQzzmrwt78g/5b1wHZQpKp+K2pwDVSWMfUBHYY3AEc+zYlT5d6QJLK6FnoFUCyAi t6tdG+TExi4z2XGJOl9vdU9GJJIt1itg1cxFWBU6l4IXT4FNwT4YTivCOwUbEqAYBAamUU/vu6u nvv6zwV1/doHCgQtmDhM4gVSUkZNN6MF7CiNfRuUvq7mUx6itJkKGKZ0WwJHsY80mtq9LYARNcS 61ZzElo3K3M2JREkz/v6KKkVTRWur1ox5Or61ql+aczmgEAcH2V06VXBk7hMen9Ca+o6eb/4/DT wW+Q5g3dVoOjPBRWhX+7UNmmFDGZUEIV7N4ZbEzYu2kLhc96trWdJ6eQv+/YL8wTdtJhmrEgwHW tArpa/UFg0GV6IeqyqrRcGv48TBQcnUTAQySof07CaKTKgFiVpLAxfwwpnpdNA9rt/lSCYhfXof 30Zt/TlFClMKa7q5bsqOSVkgKRZLUhQ06H8y3UBWWmAaotkO7hk79xq9UChLxjHYf1HmE= X-Received: by 2002:a05:600c:c16e:b0:485:5981:141b with SMTP id 5b1f17b1804b1-4870f598118mr927705e9.12.1774364738382; Tue, 24 Mar 2026 08:05:38 -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-43b646b0b0csm36743525f8f.15.2026.03.24.08.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 08:05:37 -0700 (PDT) Date: Tue, 24 Mar 2026 15:05:34 +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:18:04PM +0000, Vincent Donnefort wrote: > On Tue, Mar 24, 2026 at 02:09:50PM +0000, Vincent Donnefort wrote: > > 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(); > > Could it be better to return SMCCC_RET_NOT_SUPPORTED? Right, I will do that since it seems this is the correct approach. > > > > > break; > > > > case ESR_ELx_EC_IABT_LOW: > > > > case ESR_ELx_EC_DABT_LOW: > > > > -- > > > > 2.53.0.983.g0bb29b3bc5-goog > > > > Thanks, Sebastian