From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 6BA553AF672 for ; Thu, 7 May 2026 14:08:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778162884; cv=none; b=dudzfOPaz2EziePmmHzdBZ7ec49oz6mgG4Xq/VC1sI4Ncgbqlj0A2gGGJuvRwXTAKlVBZJlCOGNzRNEPILR3FXwA8EzyywdYfW1s5NVRxZmkc/fA24S76n2oP95aWsFNpN/QCBbvlMtKX4Q/5axXIUVqaXKwsFW36j9rgYbRVM8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778162884; c=relaxed/simple; bh=W+3hLwQ0hj3qVORYRs5AQRweLebKBlAvazuaaX7+sK4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Tdlpfu0KpMTG/k5SLQStXyEEMdsrj5h8dWAJO8KZtFIWgF2olhhSav31VNW6puB//rIiD1Q7j0c25wPjzkp22uTQ0foe6awtycu7lkfz/20PIWgYZvbveVWEmLpE5viUCBwCqHovDWZPElRFe7wxlm9s6K4Kpbt3CXqOsKLot4k= 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=KalME8XP; arc=none smtp.client-ip=209.85.215.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="KalME8XP" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-b62da7602a0so591232a12.2 for ; Thu, 07 May 2026 07:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778162883; x=1778767683; 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=zsPYNiTO0d4dTuGIfilD1PNNAucYT/R7gdAoYKJvfdM=; b=KalME8XPcZqYn98z4fA4p+PVvSKWMgDz5wrgcASx/mHqhg3xozdPHx69TZ8Z+wtDZo EO7Kqg4q+rlKda5e6IMB0hM5mkKoXKfW27adYoLHwSVcv9Mx/IZdtKx69KUBC6q99BAo 82IAPc7oksvFmIR6uMq3Z9/hKjmv7qM0Q7kLU/+wXiXu93Bs2bl763ysn6fr75EHXIID BSdWElp/aENoy1btSgbpOlOiz+ukBA8N8kNJQEjO0CDvTQ8Owu/jsUeO7ugGCe5MhRg/ 9ibPYIAFRi8ytCyXmIYmHBgTd7TvXeGizeezt3yl04GmdovEK3fjMaeyEtqD64mLHVp2 tS2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778162883; x=1778767683; 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=zsPYNiTO0d4dTuGIfilD1PNNAucYT/R7gdAoYKJvfdM=; b=reLKvAlWnCv3HC/s/bazfDVND75VUs4wwy/FdZ26PZAqBek9QXai+gdhUnIhpaHXRG EpD2Mwjpepj91Eed+GsT8vAFM6KZ8MAKggfJa+kRSl02w6/ENIP3hvlFCaYcEMqtV41R kuAxItXl2fcF9lIqXcdDryXUEZ1OW2YOLqUNmjPgQafff8m2vQmpxaOX3pkYCdi6gGUV tAtSeHhwlCSuYm86bo6fHll54SdrJJOK+HYFdIbLY0FlANCnpbchtnyAfWC3lnQy5kPl tKmCrXyzoYazP8+85V82MvN5ZIpuM6N+k4VVKmGwSVMlUgjqaWgSVdnMl++t8NS5uGu7 Th2A== X-Forwarded-Encrypted: i=1; AFNElJ8LAcLiGxVUetaznHxSEr2GWxxhYVqSF+iva61hTHq/nUwiygqeSe2+m55s4jP8PGCzBHg9Ti1syEP5VdwmB74=@vger.kernel.org X-Gm-Message-State: AOJu0YwJEQfYM+iOHeodshQpeolB/ojO4UybIIh7oa2LKRbo18HZXjVw mag8xsfdbK8u8ad1aLKHg6WhJ7PjvNjr7ApkE1+vKJOSJ5RikN49l05yAdCtG6+3PU/xrfmNAV8 MISrvOQ== X-Received: from pgct20.prod.google.com ([2002:a05:6a02:5294:b0:c79:5e8e:1248]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:a11d:b0:3a1:ed2a:1a4f with SMTP id adf61e73a8af0-3aa5a960e38mr8783458637.16.1778162882616; Thu, 07 May 2026 07:08:02 -0700 (PDT) Date: Thu, 7 May 2026 07:08:02 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: Message-ID: Subject: Re: [PATCH] KVM: SVM: Always intercept ICEBP, add INT1 selftests From: Sean Christopherson To: David Woodhouse Cc: Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Shuah Khan , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andrew Cooper , "Saenz Julienne, Nicolas" , Maciej Wieczor-Retman Content-Type: text/plain; charset="us-ascii" On Thu, May 07, 2026, David Woodhouse wrote: > From: David Woodhouse > > ICEBP (INT1, opcode 0xF1) generates a #DB that is architecturally a > trap, but on SVM it was not always intercepted. Unconditionally > intercept ICEBP on SVM to match VMX behaviour and ensure correct > event delivery semantics. > > Add two selftests exercising ICEBP: > > - int1_ept_test: verifies that ICEBP works correctly when the > exception stack page is not present (EPT/NPT fault during #DB > delivery). The IST stack is evicted via MADV_DONTNEED before > executing INT1. > > - int1_task_gate_test: verifies ICEBP delivery through a 32-bit > task gate, exercising the legacy task-switch path for #DB. > > Tested on Intel Sapphire Rapids and AMD Genoa. Without the SVM fix, > int1_task_gate_test fails on AMD with EIP pointing at ICEBP instead > of after it. With the fix, both tests pass on both platforms. Hmm, but KVM unconditionally intercepts task switches. Is this effectively working around a bug in task_switch_interception()? > Signed-off-by: David Woodhouse > --- > arch/x86/kvm/svm/svm.c | 21 ++ > tools/testing/selftests/kvm/Makefile.kvm | 2 + > .../testing/selftests/kvm/x86/int1_ept_test.c | 116 +++++++ > .../selftests/kvm/x86/int1_task_gate_test.c | 298 ++++++++++++++++++ > 4 files changed, 437 insertions(+) > create mode 100644 tools/testing/selftests/kvm/x86/int1_ept_test.c int1_host_page_fault_test? I definitely dont' want to call it "ept" since it's valid for both Intel (EPT) and AMD (NPT), but int1_tdp_test isn't accurate either since the test is also valid for shadow paging (at least, as written).