Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1305411lqd; Thu, 25 Apr 2024 11:16:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVq42YzbLYn9RWy3NB3eI9FMRB/f+hBO663Dc0BJezathN6nXSrHFqjRiHcqo6eNxD8lMTo8cT9VPzWye1dLmwh3vVAfiokPoRnMP8LQw== X-Google-Smtp-Source: AGHT+IH9q8ES9rWU9mHAdPV9yWxwuPoW1ksxYfzVOCcLVlMVmMpT5E2HnjY2qlIt9cW3Ih/T4RgM X-Received: by 2002:a05:6a00:1819:b0:6ea:f392:bce9 with SMTP id y25-20020a056a00181900b006eaf392bce9mr664094pfa.15.1714069011463; Thu, 25 Apr 2024 11:16:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714069011; cv=pass; d=google.com; s=arc-20160816; b=T7bLEmCXBDT+qR/XUIapmtscGG4If0dhUFZzCFpO8ea8VANh3xJ0YrVXA7rgxJp9L1 +Q87NDtCpOMehrhBIBuRlEOf81qZ96/z3HvuszSUVXmTO5qUDL6eyMwCIFE4KGqgb0B4 DSsTpJjZQy9rjARtNrUAhl3fCJtLNHu43LFTwQtmETiFji6rj36+Xaq2OvcYZpKy687Y 9NVvZwP1ip0gVf2n/kanLGwphcx5zJ6/tvTXkQcRi5fnC4Q8sOAPX04dD26/5j+cr6zt YdZCmAaxXKCCsZ3lkmmPNvt8IpLV7H3kJoHbxfC0LgoA++7ptahhHur5aN9P1yFoiXT6 YBmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=LVg5nuhrtwhjBtsrJV2CSF5duP9EBWfXc7R02iwvnz8=; fh=ECsMkp2RaxeIlyAkLD1G1xRRePCGGW7LCw8PsFFT0WU=; b=BioCZO7pAdw1ReDAd9WdrBGgxBuOo5bsu+xeWaq5rM/iPvrzfSYd0EV/4/QUSiyeEJ uOZA1JUStylVY5PkcoRzZ9grGRSOigXLGDwiRYyAAxGhhMOgbxHo0uJxSWTxHx1sCH3v BOu9k2mxcD8mS+4SSjwUKRreJsTtZj+o2uwMw347MUq9jH4bhOpJgLzXoGaIJGQjEiiL C5UVQMI51yE+HmzQf8O41qpoFC0dtk40pHdsb93VMaxBHUnIrbr5WqsJkQCcSpQFRH6T soc0nt1uHayME7yUdgNfKz7yUCbWeaX+RUb1eUHEE/AF3rA12wvORy0svzR50iA/iF17 hJvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ktMJAweD; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-159001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j27-20020a634a5b000000b00608e9754056si2177432pgl.133.2024.04.25.11.16.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 11:16:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ktMJAweD; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-159001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A1C4FB2192E for ; Thu, 25 Apr 2024 18:15:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C324C152DE4; Thu, 25 Apr 2024 18:14:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ktMJAweD" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 99083152501 for ; Thu, 25 Apr 2024 18:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714068873; cv=none; b=kh9joTW9T6sxQ8YFRx0aZ0zkgM29ntWxuqIk+Dlik8B9ZzbYNpAW5rGkcmskyaErBfXEcy6NaubptAQHoUdYlLE8UnXuRAkNTDn2bjaVTK0ofjyQ+ekTtDoHCB0pyzY3VJvY46n7dJBlnKSrw+TA5jjiVeOw+wXnMXvsufJ26dA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714068873; c=relaxed/simple; bh=GoixATPRkeo59e28tmuFvVP3/afktWu/87EHx44xjSI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=uiGPag8BsU/GJywqcm2jWdfCaA0MRDvjtD3i8Skxgw0ySUbRl6EcS3CGYMQU5Kf3+UJbIuVGc3LCMGvmYL0IJiT2kffNDYeCPfOk8S/BJpuOK4U3hdevf7dDwVx12Ezyp8gS9R8OVnDdhAK/AUb24w3YJWTdjgx95Gb9uRuVz3M= 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=ktMJAweD; arc=none smtp.client-ip=209.85.219.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 Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-de45dba157dso2149996276.1 for ; Thu, 25 Apr 2024 11:14:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714068870; x=1714673670; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=LVg5nuhrtwhjBtsrJV2CSF5duP9EBWfXc7R02iwvnz8=; b=ktMJAweDPoYc7itWdEeY1kJk/uEageG8Hhg1pzu0wQxgl/lC4ewDnl3E8VfB73j+cc ClobG8/RIEXG3S9Ct5DBNPjyg3I9W4bTvMjdRIIyUjKaEvoe2fic4A0p4DH6XyrIi3RE xB5k4BXuTK45a+VqcmtKvvfa8LbU1a2fMpkikdLHLyxjGJjfUQXxy/5n6yEhj51Cu+m/ M5Ndu2G4J+6a90xPWzEKd6rYm6hXMUibnXG2g1FR2+ZAKLkpYsMcT5+iQUslRlHJc2ce RSESEm/tVtFu2DIIbiRtF0kBnYSAZim/YHNbmvRFzVZYuWvW0phJA9GB3lcJ93D4Kd86 Vd7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714068870; x=1714673670; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LVg5nuhrtwhjBtsrJV2CSF5duP9EBWfXc7R02iwvnz8=; b=tRfWVu+nXF86uA6lps7TGZ/C8RDoDyF01TJmIfKd3A4T2l9RfmHijroFjWabpnz0HO rCmstk7qb4UX47MfXTIL28lDp7lgu+WVf7Ctfx7+onguBe9OWxNHgDJ77ftSia/AU5io 5OZJOu8EX6MGQfKoTF2X7rp0SrGiZJfHX8ZFv/PigfFrJ78Ki59bN723vQncQrhdL31E 5TUddKEEf8SvUdqQme2fCap/lam8eFv97xzW7bCCYlbqvAVN4iSHIeCNFSy07uE+ubNF gCgpufp5tHAaBsfAjMNqiv3VrRUlZCvWcnGhYSrkzM3Ravx8cxSE9G518nZkcEXEKOKg GUyw== X-Forwarded-Encrypted: i=1; AJvYcCXTo0uj2S8YRRm2qoes1nT7svNgzJ6PR6P8ZC45JHdHVZDn8uD5UGsk9Td3bVcN/VzW5hwBPDjNQXdFtBgGjYeuaKrRx4KLm3xDeUU7 X-Gm-Message-State: AOJu0YwQLjWaiLrETPKSfaHa1sbUdbOLC9FQ7riBPDzA3oJ9D0zgZj4M YuVQV4nHpTkgNOYM6G0VJNf9ggBwc8ZEOVImq83Ml4v8LfIthI4kKOsKVKNbMevt59c1qYv0hkZ FTg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:110e:b0:dcc:8927:7496 with SMTP id o14-20020a056902110e00b00dcc89277496mr52093ybu.5.1714068869932; Thu, 25 Apr 2024 11:14:29 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 25 Apr 2024 11:14:14 -0700 In-Reply-To: <20240425181422.3250947-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240425181422.3250947-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.769.g3c40516874-goog Message-ID: <20240425181422.3250947-3-seanjc@google.com> Subject: [PATCH 02/10] KVM: x86: Move MSR_TYPE_{R,W,RW} values from VMX to x86, as enums From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Weijiang Yang Content-Type: text/plain; charset="UTF-8" Move VMX's MSR_TYPE_{R,W,RW} #defines to x86.h, as enums, so that they can be used by common x86 code, e.g. instead of doing "bool write". Opportunistically tweak the definitions to make it more obvious that the values are bitmasks, not arbitrary ascending values. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.h | 4 ---- arch/x86/kvm/x86.h | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index 90f9e4434646..243d2ab8f325 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -17,10 +17,6 @@ #include "run_flags.h" #include "../mmu.h" -#define MSR_TYPE_R 1 -#define MSR_TYPE_W 2 -#define MSR_TYPE_RW 3 - #define X2APIC_MSR(r) (APIC_BASE_MSR + ((r) >> 4)) #ifdef CONFIG_X86_64 diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index d80a4c6b5a38..a03829e9c6ac 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -497,6 +497,12 @@ int kvm_handle_memory_failure(struct kvm_vcpu *vcpu, int r, int kvm_handle_invpcid(struct kvm_vcpu *vcpu, unsigned long type, gva_t gva); bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type); +enum kvm_msr_access { + MSR_TYPE_R = BIT(0), + MSR_TYPE_W = BIT(1), + MSR_TYPE_RW = MSR_TYPE_R | MSR_TYPE_W, +}; + /* * Internal error codes that are used to indicate that MSR emulation encountered * an error that should result in #GP in the guest, unless userspace -- 2.44.0.769.g3c40516874-goog