From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 3A66F81732 for ; Thu, 28 May 2026 02:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937019; cv=none; b=gqLLVAoyuediO30BpnFvaqsyXXLpOOBo6GOM3XXebxE//nE4iWEJr+A4ZpKefwOxm7rJUrLC/5HKmqz5TIBZpifzXYeiJybVlKEplY1L1hMILiZh5J5th/fbyvQ99ppGlCweNUzYNECbYOOqg4hahyKPMbLwCUjwrb5nT18bOeY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937019; c=relaxed/simple; bh=sSUE263pM5fCSFMCmXi9zpAfppmZLBicafOQwQzXNSM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Kb1eOmkcoK8yDRjNZjNQfWvzQ7RU3oyUOQmKxzeVjECB0bjlcV6ysNc5PZqZeqAfX/DFF7TL2/KMA92YcWgqvAxbd2L47CESO0BFVLMtVccKVaEG3YBekZFVMSzxZJmS6dsLSmekFIYmRuDgVzlwueUhyy37S2BjH+SMgApxRCo= 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=iS4TIaAk; arc=none smtp.client-ip=209.85.214.201 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="iS4TIaAk" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2b4654f9bb6so136632325ad.2 for ; Wed, 27 May 2026 19:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779937018; x=1780541818; 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=EfCR9CUr24LHfVO7c0KW/FkIupT+TiI46QESYSMQfE0=; b=iS4TIaAkkg7js+3OpvTbxcjOXCyeIxTCdtBoqqVojkK//PTrc9f0WHveoliNA0TC7m 3sYS1qc6ZmCePZmjRvQGGFSedMxqLZe3FpxHpMtTJs1x56ZSX3+UIlPMGY/RMj0lkT88 17Ip2yB0EcRq+cmVa0g4jvK6ZCxvMYJNhLpwtC57Rp8ZYbTg7TxI5qLHmoubl+AuWe6N xv7aiN5Tm3Fi+b9B/Fcb3BWxV7jnXRRDvhXvqhMUi7X+G6Tz06Bw86dbeJim/3ZE5PDT qkcFWItHtkklGR3rEYx8ASkAXAoH/utH1fHy1GXyeBHwmzw527ssLrkTtcSdxKwlRQoK 832w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779937018; x=1780541818; 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=EfCR9CUr24LHfVO7c0KW/FkIupT+TiI46QESYSMQfE0=; b=p1LnK3Z4EmtjO6UxMBuQLSyl80FyrFcSs6LximNvwTKGWPrS05NJztwQkwU3MzumlK LZOmktm4SP9OAyIFwe4tqLva80lBYt83tiokRfgAiRpADXG6CcIb4rHXdj47M4ZwbpuC Cl//9jQOd9TVjmgL2ivT4PCfS4ROJKLtrDPuVypqIkGg5FBmWCo/zgrSRGU7bwrBkOe0 NjtYHyX6HyQhm3cETjV/EpNoe5IGMD8HGwq0fiUaLuqmqbQqR2AsyWZrurr7Bn7fhum+ sniH9FR0xLB5TszCi1sL6xxQpURaqAvjAnOuUGaOpVOUPYMsPsDAraRSQhkwk7MV4poA 4Uzg== X-Forwarded-Encrypted: i=1; AFNElJ9IcYU8Zo3cAcrYmEwxPdtnnLff/o5tu8CSNpw3CoJ/qIh973GPDyn+Iks/RSdrQXoLNzOjrGNTVgqPrhw=@vger.kernel.org X-Gm-Message-State: AOJu0YxYNhIx1uOS/eTy9bNazJJrTGDn33zy+y+wD62jVzK4/EvT2GDV tQ3dXMM3WOVQlqzVsN9Hv0xHvlhk7WAVqF5N81wXYmR84QP4CuKWNjTpn71qhFF/fd5ZlIOksUZ KcIaYzg== X-Received: from plqu16.prod.google.com ([2002:a17:902:a610:b0:2bc:c295:bdd2]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1b10:b0:2b2:4d36:7ba with SMTP id d9443c01a7336-2beb058078cmr256874455ad.0.1779937017326; Wed, 27 May 2026 19:56:57 -0700 (PDT) Date: Wed, 27 May 2026 19:56:56 -0700 In-Reply-To: <20260527234711.4175166-16-yosry@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260527234711.4175166-1-yosry@kernel.org> <20260527234711.4175166-16-yosry@kernel.org> Message-ID: Subject: Re: [PATCH v7 15/17] KVM: selftests: Allocate a dedicated guest page for x86 L2 guest stack From: Sean Christopherson To: Yosry Ahmed Cc: Paolo Bonzini , Jim Mattson , Dapeng Mi , Sandipan Das , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Wed, May 27, 2026, Yosry Ahmed wrote: > Instead of relying on the L1-provided stack for L2, which is usually an > array on L1's own stack, allocate a dedicated page of VM memory for the > L2 stack in vcpu_alloc_{vmx/svm}() and use that as L2's RSP in the > VMCS/VMCB instead of the L1-provided value. > > Most L1 guest code does not do anything with the L2 stack other than > stuff it in RSP, so this change is transparent and the L1-provided stack > is silently ignored. The only exception is memstress nested L1 code > which puts the vCPU index on L2's stack, so update this code to use the > newly allocated stack. > > L1-provided stacks will be dropped and cleaned up separately. > > Suggested-by: Sean Christopherson > Signed-off-by: Yosry Ahmed > --- Blech. This exposed a nasty edge in selftests. For tests that enable TDP, the slots need to be identity mapped *after* allocating SVM/VMX. Found out the hard way: the gPAT test starting failing. Not worth worrying about right now, just one more wart in selftests that needs to be cleaned up. diff --git tools/testing/selftests/kvm/x86/svm_nested_pat_test.c tools/testing/selftests/kvm/x86/svm_nested_pat_test.c index 392ede74589e..6798b1b9d910 100644 --- tools/testing/selftests/kvm/x86/svm_nested_pat_test.c +++ tools/testing/selftests/kvm/x86/svm_nested_pat_test.c @@ -115,12 +115,14 @@ static void run_test(void *guest_code, bool do_save_restore, int nr_iters) vm_enable_cap(vm, KVM_CAP_DISABLE_QUIRKS2, KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT); - if (npt_enabled) { + if (npt_enabled) vm_enable_npt(vm); - tdp_identity_map_default_memslots(vm); - } vcpu_alloc_svm(vm, &svm_gva); + + if (npt_enabled) + tdp_identity_map_default_memslots(vm); + vcpu_args_set(vcpu, 1, svm_gva); nr_iterations = nr_iters;