linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev, Steffen Eiden <seiden@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>,
	Oliver Upton <oupton@kernel.org>,
	kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	linux-s390@vger.kernel.org, Marc Zyngier <maz@kernel.org>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>
Subject: Re: [PATCH v2 11/20] KVM: s390: arm64: Query Available Arm features
Date: Tue, 1 Sep 2026 13:44:09 +0200	[thread overview]
Message-ID: <d6fcf081-7613-4d3a-ab62-6c4f9a42816b@linux.ibm.com> (raw)
In-Reply-To: <20260831194654.39B451F000E9@smtp.kernel.org>

On 8/31/26 9:46 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
> - [Critical] The EX_TABLE entry in the `qaaf` inline assembly incorrectly places the exception fixup label on the non-faulting `lhi` instruction instead of the potentially faulting `.insn` instruction, which will cause unhandled hardware exceptions to panic the kernel.
> - [High] `aef_sysfs_init()` unconditionally calls `aef_init_save_area()`, failing to skip it when the AEF facility is not present, causing a crash on older hardware.
> - [High] Off-by-two index error when accessing the QAAF registers array in `kvm_qaaf_read_ftr_reg()`, causing KVM to read incorrect memory offsets for all features.
> - [High] If QAAF initialization fails, the global capability flag `info.arm_guest_supp` is not cleared, leading KVM to initialize using uninitialized hardware capability data.
> --

[...]

>> diff --git a/arch/s390/kernel/aef.c b/arch/s390/kernel/aef.c
>> new file mode 100644
>> index 0000000000000..825e2643a8921
>> --- /dev/null
>> +++ b/arch/s390/kernel/aef.c
> [ ... ]
>> +static int  __init aef_query_info(void)
>> +{
>> +	int ret;
>> +
>> +	if (IS_ENABLED(CONFIG_KVM_S390_ARM64)) {
>> +		info.sae_avail = sclp.has_aef;
>> +		info.ptff_avail = ptff_query(PTFF_QAGTO) &&
>> +				  ptff_query(PTFF_QAGPT);
>> +		info.arm_guest_supp = info.sae_avail && info.ptff_avail;
>> +	}
>> +	if (!info.sae_avail)
>> +		return 0;
>> +
>> +	ret = qaaf(QAAF_FC_QMC, (union qaaf_block *)&qmc);
>> +	if (ret)
>> +		return ret;
> 
> [Severity: High]
> If the qaaf instruction fails and returns an error here, `info.arm_guest_supp`
> remains set to true.
> 
> Because aef_sysfs_init() is called via an arch_initcall, the initialization
> failure is ultimately ignored by the kernel. Later, kvm_s390_arm64_init()
> checks `aef_info()->arm_guest_supp` and will proceed to initialize KVM using
> the uninitialized `qmc` block.
> 
> Should `info.arm_guest_supp` be cleared before returning when qaaf() fails?

No, we can instead check the sclp bit for sae_avail and early return 
before the assignments.
I don't see a gain in having this information shadowed considering the 
two patchsets that are floating around. Maybe you need it at a later time?


sae_avail is also used in patch #20 where it makes even less sense.
Either the machine and KVM have sae capabilities or we don't need the 
sysfs files. So why even add it as a file?

It's not like UV where we need to opt in, it's either supported or not.
If it's not supported there's no need to have sysfs files.


> 
> [ ... ]
>> +static int __init aef_sysfs_init(void)

aef_info_init()?

>> +{
>> +	int rc = -ENOMEM;
>> +
>> +	if (!IS_ENABLED(CONFIG_KVM_S390_ARM64))
>> +		return 0;
>> +
>> +	rc = aef_query_info();
>> +	if (rc)
>> +		return rc;
>> +
>> +	rc = aef_init_save_area();
>> +	if (rc)
>> +		return rc;
> 
> [Severity: High]
> Will this execute the new qaaf instruction unconditionally on all hardware?
> 
> aef_query_info() correctly returns 0 if the AEF facility is absent (since
> `info.sae_avail` would be false). However, aef_init_save_area() is called
> immediately after without checking if the facility is actually supported.
> 
> Could this trigger an operation exception on older hardware?

> 


  reply	other threads:[~2026-09-01 11:44 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 14:55 [PATCH v2 00/20] KVM: arm64 on s390 System Register Handling Steffen Eiden
2026-08-31 14:55 ` [PATCH v2 01/20] KVM: arm64: Refactor idreg caching into dedicated structure Steffen Eiden
2026-08-31 18:06   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 02/20] KVM: arm64: Extract number of sys_reg_desc into a constant Steffen Eiden
2026-08-31 18:08   ` sashiko-bot
2026-09-01  7:48   ` Marc Zyngier
2026-08-31 14:55 ` [PATCH v2 03/20] arm64: sysreg: Define OSLSR_EL1_OSLK_MASK Steffen Eiden
2026-08-31 18:18   ` sashiko-bot
2026-09-01  7:51   ` Marc Zyngier
2026-09-01  9:25     ` Steffen Eiden
2026-08-31 14:55 ` [PATCH v2 04/20] arm64: Share more arm64 headers with s390 Steffen Eiden
2026-08-31 18:31   ` sashiko-bot
2026-09-01  8:08   ` Marc Zyngier
2026-08-31 14:55 ` [PATCH v2 05/20] KVM: s390: arm64: Prepare for sharing more arm64 code Steffen Eiden
2026-08-31 18:42   ` sashiko-bot
2026-09-01  8:15   ` Marc Zyngier
2026-08-31 14:55 ` [PATCH v2 06/20] KVM: arm64: Prepare sys_regs.c for sharing with s390 Steffen Eiden
2026-08-31 18:45   ` sashiko-bot
2026-09-01  8:17   ` Marc Zyngier
2026-09-01  9:29     ` Steffen Eiden
2026-08-31 14:55 ` [PATCH v2 07/20] KVM: arm64: Share more arm64 code " Steffen Eiden
2026-08-31 19:01   ` sashiko-bot
2026-09-01  8:30   ` Marc Zyngier
2026-08-31 14:55 ` [PATCH v2 08/20] s390: tools: Allow sharing arm64/kvm headers Steffen Eiden
2026-08-31 19:03   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 09/20] s390: Introduce read/write ARM sysreg instructions Steffen Eiden
2026-08-31 19:16   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 10/20] s390: Add functions to query arm guest time Steffen Eiden
2026-08-31 19:24   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 11/20] KVM: s390: arm64: Query Available Arm features Steffen Eiden
2026-08-31 19:46   ` sashiko-bot
2026-09-01 11:44     ` Janosch Frank [this message]
2026-09-01 14:25       ` Steffen Eiden
2026-08-31 14:55 ` [PATCH v2 12/20] KVM: s390: arm64: Implement feature sanitisation Steffen Eiden
2026-08-31 20:11   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 13/20] KVM: s390: arm64: Implement arm sysreg managing infrastructure Steffen Eiden
2026-08-31 20:33   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 14/20] KVM: s390: arm64: Integrate sysreg into the host Steffen Eiden
2026-08-31 21:15   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 15/20] KVM: s390: arm64: Use QAAF init save area Steffen Eiden
2026-08-31 21:32   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 16/20] KVM: s390: arm64: Implement exception injection Steffen Eiden
2026-08-31 21:38   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 17/20] KVM: s390: arm64: Finalize page fault handling Steffen Eiden
2026-08-31 21:52   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 18/20] KVM: s390: arm64: Implement SVE for arm guests Steffen Eiden
2026-08-31 22:16   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 19/20] KVM: s390: arm64: Promote PTRAUTH capability Steffen Eiden
2026-08-31 22:35   ` sashiko-bot
2026-08-31 14:55 ` [PATCH v2 20/20] s390: Report AEF features to sysfs Steffen Eiden
2026-08-31 22:43   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d6fcf081-7613-4d3a-ab62-6c4f9a42816b@linux.ibm.com \
    --to=frankja@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-s390@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=seiden@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).