From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 3F32436A03D for ; Fri, 6 Mar 2026 16:35:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772814922; cv=none; b=UeAE+HwqvMQTU7dcckUwFeK0Vt898yVCdeOmWG17froU4j4CRQb6VJbTyIk5OMLLamv4U36PYUARugstAZEa8Opw9JZ0SKmDiuH4tvN9CkLgiubgD73E2nnoENmF5qeTgW8a7u83FmKAQPDtxvppLGepAIEe17wyot6fPDboZ5Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772814922; c=relaxed/simple; bh=Dn7lHsHJzgWeOdy/kkyhlFzB8fwBn38eRfLOB93zuxU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ShsJbTNbcwEJzaVat53RgKZolH7qFb1Em9OS8rZ5El7z8XalXvfzAtU5YDDcwvUpZYOIkulOJ4xZwnoHCV0uVQCYp0bQ5uE/P2UJMRjKClH7OjvSWHAosKrYCEIYZmSoaNdvBZzrzAIWeing3t4OjszuYE7FBDypu/O3YdxfI6k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=dh6dLrI6; arc=none smtp.client-ip=209.85.214.202 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--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dh6dLrI6" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2ae4f27033cso59356785ad.3 for ; Fri, 06 Mar 2026 08:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772814920; x=1773419720; 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=DquZyRH4SqVhjA3d7wMGbHzzOoe5pUQf3Zgxi/ZUE08=; b=dh6dLrI6regOmIYgTPzwm06GC4KGoODf3FXkbHDEAvWimRyDBOHggDgDaUhjcTmj63 LcJa58POEJXKCaX2LN06oTfcNGFAVN1DFpOeiHB+a19yWYQem37SPNWHlDBuwlPG9Tj2 KWkk34YYobKN/tQtJW6ae9bQjnpSJXdl/iJfsysx50a3gr7Wd8a/iEZwX1TkCgx68JYs waioiDtr85zPDqAnACJ31wc0zFiahtOOPRavdiJvhhCsvDN3Wn0rcDm94VQ+IrHfwWYb 3JqJcQ3wOrDJjsoG+CB7YOjQ3OwC/KT0nLg7lHWiSqy4pXvb0SEo2fVyoYk0fE66fc6V mP0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772814920; x=1773419720; 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=DquZyRH4SqVhjA3d7wMGbHzzOoe5pUQf3Zgxi/ZUE08=; b=OhFqDX5AvqW+UDQ/GoRVEBDA3v72NgD/42SCYg+BKHpcvrbhpOs8mAqRw5AjVgTElF G2yj0xgFoHVBUya0HmCLQ08I7usLRuKXhAV9bZOY4kwUz4PZUdRM4pZRahG6KuZovpjk 383YwTEYfBs4jBwqGjSo6LG2EmVTBLOgYkqY1szHlNYpYde4k/chZHe+3jnO473YHBJh qUflYqo4j+J2AEJicR/Y/8MrwqwkYqgf2485/dDqaTg7lOWI7NtXK2HSXKLXUgkQbNCB QWvQ4BcuOup8bmUYSsLuQop/LeMYKQMU42MvGL6TERgPP6iPOc9MQRkw4fZj8Tyzq2vs hsxA== X-Forwarded-Encrypted: i=1; AJvYcCWTYaMr3pIqSvjTSvpKIIV12gNPbR1/cIHA5WDtDKLEviEH9SHPocFr8sybA5eKe7TvIK9qQrXJCts423Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yxt9Ptbz0f4r54IUFObhQOidOyhFebPWb9gnRZDf/nBwWCjCo8P /YQDhIWREMMTsvuf8ChhNVaraj+i4D8A82G4Y9SxTGGghKd79nu/a91ZO5lMm7XRQFndpAsQKwO My/6NyQ== X-Received: from pldr11.prod.google.com ([2002:a17:903:410b:b0:2ae:4482:4ee0]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:13d0:b0:2ae:6778:9dba with SMTP id d9443c01a7336-2ae82458a43mr30977535ad.41.1772814920418; Fri, 06 Mar 2026 08:35:20 -0800 (PST) Date: Fri, 6 Mar 2026 08:35:19 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260303003421.2185681-1-yosry@kernel.org> <20260303003421.2185681-27-yosry@kernel.org> Message-ID: Subject: Re: [PATCH v7 26/26] KVM: selftest: Add a selftest for VMRUN/#VMEXIT with unmappable vmcb12 From: Sean Christopherson To: Yosry Ahmed Cc: Jim Mattson , Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Fri, Mar 06, 2026, Yosry Ahmed wrote: > > diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c > > index b191c6cab57d..78a542c6ddf1 100644 > > --- a/arch/x86/kvm/svm/nested.c > > +++ b/arch/x86/kvm/svm/nested.c > > @@ -1105,10 +1105,8 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu) > > > > vmcb12_gpa = svm->vmcb->save.rax; > > err = nested_svm_copy_vmcb12_to_cache(vcpu, vmcb12_gpa); > > - if (err == -EFAULT) { > > - kvm_inject_gp(vcpu, 0); > > - return 1; > > - } > > + if (err == -EFAULT) > > + return kvm_handle_memory_failure(vcpu, X86EMUL_UNHANDLEABLE, NULL); > > Why not call kvm_prepare_emulation_failure_exit() directly? Mostly because my mental coin-flip came up heads. But it's also one less line of code, woot woot! > Is the premise that kvm_handle_memory_failure() might evolve to do more > things for emulation failures that are specifically caused by memory > failures, other than potentially injecting an exception? Yeah, more or less. I doubt kvm_handle_memory_failure() will ever actually evolve into anything more sophisticated, but at the very least, using kvm_handle_memory_failure() documents _why_ KVM can't handle emulation. On second thought, I think using X86EMUL_IO_NEEDED would be more appropriate. The memremap() is only reachable if allow_unsafe_mappings is enabled, and so for a "default" configuration, failure can only occur on: if (is_error_noslot_pfn(map->pfn)) return -EINVAL; Which doesn't _guarantee_ that emulated I/O is required, but we're definitely beyond splitting hairs at that point.