From mboxrd@z Thu Jan 1 00:00:00 1970 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 0CE221993B7 for ; Wed, 8 Jan 2025 17:18:18 +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=1736356700; cv=none; b=PoqkZOLQUHMx7kdRth6mWkA5j7Rdi/GoygoaU53B0oTFAIsg3tAxztxW34VCJfuAYn/YvLpFlpV6gdSC+MdW1QxQD7oEBbqwtUtJBLcxrePXbaBR/lSp+6AcH/D2izWjbWsAPomUbk+/n/hRlwoiWDD17D4g6ps+fA6Q90r1XoA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736356700; c=relaxed/simple; bh=bxbzPDPzeo6Mj+J2K3yE7tGlJ/vd/UEgWfWw2x4x1Pg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=opCItys5eJSPfvw1Ths+85oU5/mUg3jvvIQluSFpFztzKonFvcSmAlVuMtONe+TAWpnOGlWT283dEirXNRFz7PraXp+o2y51+eU9a7vdMuHjVmg48MfrepQorwqQRqhors21tLh7z38lBAnmuXYcQ8/O/WBTgRg3JFnC9pMa9JM= 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=3MJoio7w; 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--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="3MJoio7w" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef91d5c863so45525a91.2 for ; Wed, 08 Jan 2025 09:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736356698; x=1736961498; 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=Hy1OImYgQQWoSU9wIssXYzkU46oMuxX1ekNYL4JguZU=; b=3MJoio7wt0Vty0LHKQ/JERH/PkLdt7GPRHoYwJURT1YUPQoWBf9rvRVfBf+21YuqWx CLFF4kus6b0Ew0zH1iJ8XkwGLhUzjxE5KWsOnPIxUd5ppLjcjZsAiSSaoIw/bAJ46ZQr 5M4MLDlrCS1IbOkmLD7pu4f7wsGKKRACS6PuQTQeiAVR8yxZIMpIZC5naak0ww/esZoo M4hT7l86iErclhzQAPIZSVmiuTldkusZxbFpnFAMCITLMhlaaYEui7k5L5MPlX0fhciA qIrsABd+rXOeV676opJC2+7NfbQ0NpWyAz8IAFoLCczl95NIrNsNE6dc7lCLdyi6NjYw nJ3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736356698; x=1736961498; 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=Hy1OImYgQQWoSU9wIssXYzkU46oMuxX1ekNYL4JguZU=; b=fQX48SqC/8uDBBa6K0ApdqyADU4Tiv40dq1OcMHrX2AnPVgaFkO1I+ccOvIRkbcg6Z QSFUh64u92AhdXgZ3DJwaV5WuwUDEJslibdmFJ5aOhXb2osWG+Xt4SPMbcFe6Mt1vnyn kKvm1R/+IWCIEYoQbLzEraYkH0s+vY+qaUaX+fN5vG4diue68a2Eeh1c8IUqGZVAhatD HTod75lHvPGUIQjr35CDNsW5DH0ECcwCK1IFVFMfsi1u8agGpyr4gtfJR2CqhWiFprIB HaneiZAHlDxl9C4lSKg95GC/c+C9VmlyeHh/0j59AxUt+nBK2UhLzgi5ZLKycor9GXfL HtKw== X-Forwarded-Encrypted: i=1; AJvYcCUhONFN1v6NUB6g1aRc/OJgFsI8frGl1Z1rVmpp6vZZKfpBbEJ5YGUMsK2O8ld0WbTe5rHMOmSy97/G7y8=@vger.kernel.org X-Gm-Message-State: AOJu0Yynwulv63S+quOwQgJ7ljCKbbjlsJTCKneLb1QbRzQavapVzad8 usCnJosLS0PgjvTa3z3HV8xPZShmGD/QZHKIIPpo4/IHTBLXWxHNWLDro3Y4N7T4o/dwTc2mGWh 83g== X-Google-Smtp-Source: AGHT+IHfHcu56E1hc5dqPiSS91EWf26xDr6vcxJmjXCGZbU/oon6eBARqLMgUGZz0Y1H8HxUjhwHjPZmJCc= X-Received: from pfbbd43.prod.google.com ([2002:a05:6a00:27ab:b0:728:aad0:33a4]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3a02:b0:726:f7c9:7b1e with SMTP id d2e1a72fcca58-72d21f4c0c6mr5435061b3a.13.1736356698391; Wed, 08 Jan 2025 09:18:18 -0800 (PST) Date: Wed, 8 Jan 2025 09:18:17 -0800 In-Reply-To: <20250108154901.GFZ36ebXAZMFZJ7D8t@fat_crate.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241202120416.6054-1-bp@kernel.org> <20241202120416.6054-4-bp@kernel.org> <20241216173142.GDZ2Bj_uPBG3TTPYd_@fat_crate.local> <20241230111456.GBZ3KAsLTrVs77UmxL@fat_crate.local> <20250108154901.GFZ36ebXAZMFZJ7D8t@fat_crate.local> Message-ID: Subject: Re: [PATCH v2 3/4] x86/bugs: KVM: Add support for SRSO_MSR_FIX From: Sean Christopherson To: Borislav Petkov Cc: Borislav Petkov , X86 ML , Paolo Bonzini , Josh Poimboeuf , Pawan Gupta , KVM , LKML Content-Type: text/plain; charset="us-ascii" On Wed, Jan 08, 2025, Borislav Petkov wrote: > > And do you know what 0xd23f corresponds to? > > How's that: > > $ objdump -D arch/x86/kvm/kvm.ko > ... > 000000000000d1a0 : > d1a0: e8 00 00 00 00 call d1a5 > d1a5: 55 push %rbp > ... > > d232: e8 09 93 ff ff call 6540 > d237: 85 c0 test %eax,%eax > d239: 0f 88 f6 01 00 00 js d435 > d23f: f3 90 pause > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > d241: e8 00 00 00 00 call d246 > d246: 48 89 c3 mov %rax,%rbx > d249: e8 00 00 00 00 call d24e > d24e: 84 c0 test %al,%al > > > Which makes sense :-) Ooh, it's just the MSR writes that increased. I misinterpreted the profile statement and thought that something in KVM was jumping from ~0% to 4.31%. If the cost really is just this: 1.66% qemu-system-x86 [kernel.kallsyms] [k] native_write_msr 1.50% qemu-system-x86 [kernel.kallsyms] [k] native_write_msr_safe vs 1.01% qemu-system-x86 [kernel.kallsyms] [k] native_write_msr 0.81% qemu-system-x86 [kernel.kallsyms] [k] native_write_msr_safe then my vote is to go with the user_return approach. It's unfortunate that restoring full speculation may be delayed until a CPU exits to userspace or KVM is unloaded, but given that enable_virt_at_load is enabled by default, in practice it's likely still far better than effectively always running the host with reduced speculation. > > Yeah, especially if this is all an improvement over the existing mitigation. > > Though since it can impact non-virtualization workloads, maybe it should be a > > separately selectable mitigation? I.e. not piggybacked on top of ibpb-vmexit? > > Well, ibpb-on-vmexit is your typical cloud provider scenario where you address > the VM/VM attack vector by doing an IBPB on VMEXIT. No? svm_vcpu_load() emits IBPB when switching VMCBs, i.e. when switching between vCPUs that may live in separate security contexts. That IBPB is skipped when X86_FEATURE_IBPB_ON_VMEXIT is enabled, because the host is trusted to not attack its guests. > This SRSO_MSR_FIX thing protects the *host* from a malicious guest so you > need both enabled for full protection on the guest/host vector. If reducing speculation protects the host, why wouldn't that also protect other guests? The CPU needs to bounce through the host before enterring a different guest. And if for some reason reducing speculation doesn't suffice, wouldn't it be better to fall back to doing IBPB only when switching VMCBs?