From nobody Fri Dec 19 17:01:28 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 57DD62D9EF6 for ; Mon, 13 Oct 2025 18:59:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760381958; cv=none; b=D+E9XwLjdWl6uJx05LXwgtrYQK6HAmaTjvIuE0OysXg75bks7rThVYBm4zj8S3bcNUDUtRwcJDsY16AMl1SH+m/zDhJhUX0iKCVUWESP41RVWpI2tFGfd3MLlbZJK/sTXI0DYt01Hiadvm5fqIoLqdUxxbouS0UyGvOPKe+YCeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760381958; c=relaxed/simple; bh=4FjZOwY6iLfIUw1O3aAoof090jEORs2O09E0JM09G0s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=H2NSjpurG1lZup/0f17unVWI773lP3wMoUToIjNDkJ1hui+qXg8VqQciGazoprhNkvq9Fk2TFt6pVUg1m4jiiC27ih9qs5KfzMBU5DWtoUKt/+CfSaRS66a5l4lk1ICmO/mNcEoVTEbOLX7ftLA83DNE3VbnRXNMkTGG2/xca+U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jiaqiyan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=MiQOklbu; arc=none smtp.client-ip=209.85.216.74 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=flex--jiaqiyan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MiQOklbu" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-32ec69d22b2so9805355a91.1 for ; Mon, 13 Oct 2025 11:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760381956; x=1760986756; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QUhJwaTYTLlWJW6PvotT0NnhH894vpuEW0sON2hXEJ4=; b=MiQOklbuBRewg0P6/TJXUb6SFeHmZ2zaX9lJWr3vgQYYO4opHmnAyECQNHHDOrS+Te g1ZvDz03bj6c/OjybuMY8ZR6KeW4Mv3oTo4QVSKO9TNrpDVm40s6Mzo0N3+WZU8Skqh8 nrsSkIINSzSFbaXatoSImrOZOgIqk4992gqOXaDBeMOfUa+TULT1OCTBPeS7I+3tctmQ 3pMTppC1PGo3W8DTLdIFj6Z5gShrbD5VsqL74xF2UdcsXP+jO5Pxk5IhNBF0e9/Nvw6h uueIfVmIhfYV+aRstH4xn9W08giGMUfK95gevjC0oip8qCAPNMH7UUnjep+t1/aq0y8Z N3RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760381956; x=1760986756; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QUhJwaTYTLlWJW6PvotT0NnhH894vpuEW0sON2hXEJ4=; b=KpEB9+ggBWp0O3AVaIO+L2/uKv86j6hPbTorzwDP9hMTSvCQMYLHDsCLGeKxOfJrdH 3e+wUrrEMylZNcYMxMDloUg0N5avCgSsOTWj96ev1sKVZaAIpuyyapKAusSwtlVSsozC WbxsdFvdcGyOotS7r2ZbRznQmSp3fcNKZm27U5G3yvHeabGHBNEgk1Fv248fuCT3n1Hq 6fBBtCCWfSzz7Iv2D0ZtWLPnnZ2YHg9kjb1O+6joRpFyAL4Loj6iu5RPmpX5aVk3sLVc C5neqKyC5nsYr2CsaxnehLFFCn/zx9alGfbKxv79fVbSTagj4tN163P+OeQ8AFHBGrYD T8zQ== X-Forwarded-Encrypted: i=1; AJvYcCWsNbPQftN7tGlHkHbmHRG2qQ+/v0FEXXxa0CV5SimF+AB33CqguM8PXRl4bBtuCXiNCHzTE4cCw5ddkGA=@vger.kernel.org X-Gm-Message-State: AOJu0YwGuc/6P7dcvOG9x7v8q5MdDrG2TUi/vEGbG3zLoBhcq/enhq8x Y+sRLkhrmIU3uZrKqmoqkBZ4UY4PGD1bevMjZrk2BiHKOPJwrsmPWboVTzgVpMPWkQf6QhtQF+q WYd+ceGqeXHrhtg== X-Google-Smtp-Source: AGHT+IGwypBb0mDfdIn0W0YpuT1qvoN3uirrptacGmPUlbNvOoNVC+pU0bOpfORyj1duGVbXmE/Ph8TFfVXERw== X-Received: from pjuq15.prod.google.com ([2002:a17:90a:d38f:b0:32e:ae63:2947]) (user=jiaqiyan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1641:b0:330:4a1d:223c with SMTP id 98e67ed59e1d1-33b5116a6a6mr32151423a91.15.1760381955636; Mon, 13 Oct 2025 11:59:15 -0700 (PDT) Date: Mon, 13 Oct 2025 18:59:03 +0000 In-Reply-To: <20251013185903.1372553-1-jiaqiyan@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251013185903.1372553-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.51.0.760.g7b8bcc2412-goog Message-ID: <20251013185903.1372553-4-jiaqiyan@google.com> Subject: [PATCH v4 3/3] Documentation: kvm: new UAPI for handling SEA From: Jiaqi Yan To: maz@kernel.org, oliver.upton@linux.dev Cc: duenwen@google.com, rananta@google.com, jthoughton@google.com, vsethi@nvidia.com, jgg@nvidia.com, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, pbonzini@redhat.com, corbet@lwn.net, shuah@kernel.org, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Jiaqi Yan Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document the new userspace-visible features and APIs for handling synchronous external abort (SEA) - KVM_CAP_ARM_SEA_TO_USER: How userspace enables the new feature. - KVM_EXIT_ARM_SEA: exit userspace gets when it needs to handle SEA and what userspace gets while taking the SEA. Signed-off-by: Jiaqi Yan --- Documentation/virt/kvm/api.rst | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 6ae24c5ca5598..43bc2a1d78e01 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -7272,6 +7272,55 @@ exit, even without calls to ``KVM_ENABLE_CAP`` or si= milar. In this case, it will enter with output fields already valid; in the common case, the ``unknown.ret`` field of the union will be ``TDVMCALL_STATUS_SUBFUNC_UNSUP= PORTED``. Userspace need not do anything if it does not wish to support a TDVMCALL. + +:: + /* KVM_EXIT_ARM_SEA */ + struct { + #define KVM_EXIT_ARM_SEA_FLAG_GPA_VALID (1ULL << 0) + __u64 flags; + __u64 esr; + __u64 gva; + __u64 gpa; + } arm_sea; + +Used on arm64 systems. When the VM capability KVM_CAP_ARM_SEA_TO_USER is +enabled, a VM exit is generated if guest causes a synchronous external abo= rt +(SEA) and the host APEI fails to handle the SEA. + +Historically KVM handles SEA by first delegating the SEA to host APEI as t= here +is high chance that the SEA is caused by consuming uncorrected memory erro= r. +However, not all platforms support SEA handling in APEI, and KVM's fallback +is to inject an asynchronous SError into the guest, which usually panics +guest kernel unpleasantly. As an alternative, userspace can participate in= to +the SEA handling by enabling KVM_CAP_ARM_SEA_TO_USER at VM creation, after +querying the capability. Once enabled, when KVM has to handle the guest +caused SEA, it returns to userspace with KVM_EXIT_ARM_SEA, with details +about the SEA available in 'arm_sea'. + +The 'esr' field holds the value of the exception syndrome register (ESR) w= hile +KVM taking the SEA, which tells userspace the character of the current SEA, +such as its Exception Class, Synchronous Error Type, Fault Specific Code a= nd +so on. For more details on ESR, check the Arm Architecture Registers +documentation. + +The following values are defined for the 'flags' field + + - KVM_EXIT_ARM_SEA_FLAG_GPA_VALID -- the faulting guest physical address + is valid and userspace can get its value in the 'gpa' field. + +Note userspace can tell whether the faulting guest virtual address is valid +from the FnV bit in 'esr' field. If FnV bit in 'esr' field is not set, the +'gva' field hols the valid faulting guest virtual address. + +Userspace needs to take actions to handle guest SEA synchronously, namely = in +the same thread that runs KVM_RUN and receives KVM_EXIT_ARM_SEA. One of the +encouraged approaches is to utilize the KVM_SET_VCPU_EVENTS to inject the = SEA +to the faulting VCPU. This way, the guest has the opportunity to keep runn= ing +and limit the blast radius of the SEA to the particular guest application = that +caused the SEA. Userspace may also emulate the SEA to VM by itself using t= he +KVM_SET_ONE_REG API. In this case, it can use the valid values from 'gva' = and +'gpa' fields to manipulate VCPU's registers (e.g. FAR_EL1, HPFAR_EL1). + :: =20 /* Fix the size of the union. */ @@ -8689,6 +8738,18 @@ This capability indicate to the userspace whether a = PFNMAP memory region can be safely mapped as cacheable. This relies on the presence of force write back (FWB) feature support on the hardware. =20 +7.45 KVM_CAP_ARM_SEA_TO_USER +---------------------------- + +:Architecture: arm64 +:Target: VM +:Parameters: none +:Returns: 0 on success, -EINVAL if unsupported. + +This capability, if KVM_CHECK_EXTENSION indicates that it is available, me= ans +that KVM has an implementation that allows userspace to participate in han= dling +synchronous external abort caused by VM, by an exit of KVM_EXIT_ARM_SEA. + 8. Other capabilities. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.51.0.760.g7b8bcc2412-goog