From patchwork Fri Feb 9 22:07:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 20186 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1166332dyd; Fri, 9 Feb 2024 14:28:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxcF2Rfq2HP9hXveP4Wj5vSCIWi1jQGfsUcLSsoXED638MG4Bn/4RO59x/48gLUShdW4AU X-Received: by 2002:a05:6a21:670f:b0:19e:989e:1993 with SMTP id wh15-20020a056a21670f00b0019e989e1993mr530469pzb.29.1707517715806; Fri, 09 Feb 2024 14:28:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707517715; cv=pass; d=google.com; s=arc-20160816; b=QDMZ5IoN0lggSzTKEZgaNzwNKeSbNf/F3MJkRAV/BLCI5bu8oF0Fl8cttF+zQV/MX+ mYNL9Kf4Bw83WqEiUy06Vktd2Z5gsNov7os8EUQG8stSmetvYJR3z8YzDac46/a94hpe uXsi574lgzSr2dET6T/4zPCYpDfdFzBM9pdcAB63a+7uU8WyCgPKn1id/s5AgZH8gXRV ORD+KpJ6qgXjziGZ0ZR8dMBBqb28MoPTdDGZrqmByZf0SF5+BTVTufqi8dqW2+TvmN2Q vyZJo6Vjp5+LmdkyYnKJe0euSX+ZDR/VKpfeb2ZaENcXWRMDmGdHkLP3Oj9KUhr1+bod A4Kw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:reply-to:dkim-signature; bh=XgDgnWq7Lrk26+EQn5hdWDLpi21lwuFWEvrXKhI43Hc=; fh=7dSn7joAHfnpAlQvUl2+RzNXJP86BLY4Ke2EbKFnf6Y=; b=lb+7F6/QqNRV+KAPIn/CMHASZrd9ymvK9tbRjANKv6Z7DvaXtQ7OxHyd7JSnA6zDxE zNq8iDqX/ohKgvAFoNXGm+fL/pia16AIhqA7qjw1Zld0OUgD0muiVyAqxjEiTQN/B6wN Y845Y6dhZjBtEExwD5/baLR+obvhaF1oSpkulo0Q5kAIZwKIvkgEtofjFjkocUhDXtgb C3lVbdwAXpkCO1/hWX2omF29p+s608PHs4GzGSw/ePWalLALostTYWNfjQnOdsDwF2Ic Yn4HYmdNbar9i5tuI2EIMdc9kiBrwF1IMJVgGzxLGaoHib5i5UnWUm1WF1LMRbBomPxH hm5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wJ8w88xb; 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-60064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60064-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCVE2yJaqGOefxuDt74vcvRd5A+2gdRnMAOHe47RJJpjpI3y6SKwxOk6O6L9USt/7AE6DRxee1cAgEi44BYyQ658A2yevw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id qd6-20020a17090b3cc600b00296e04429dfsi2302598pjb.149.2024.02.09.14.28.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 14:28:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wJ8w88xb; 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-60064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60064-ouuuleilei=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 6E971B23FAE for ; Fri, 9 Feb 2024 22:08:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AA3336AF6; Fri, 9 Feb 2024 22:07:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wJ8w88xb" 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 7BD882E40E for ; Fri, 9 Feb 2024 22:07:54 +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=1707516475; cv=none; b=M/dNJbot1Qb3GKTKv98/hVvhAyULJSHhY7N6E58B2fF3gOWoTXDHC2uEc6VazTsfk9jnUfr86qHNKBh5hnAhrtVhHhuyjKNesBdhtXs5M2f9kdvxUkBydrXd4l38wfiilzVWj+x91bcxrXenqsTAYNC/jB9jLS5Fj8fHbjsXUfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707516475; c=relaxed/simple; bh=8XTkEQ6LYwg5FS5OHdChXniWfwTkJDHlQuODzLRJI10=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=jDmbmqasOOL0FE/G9FlXuYwjfS6mr9NVb6hnWBwC96lkypJhwN2b8q0g4+Qu2CeQZTixIm/RdzOI0lzb3P5It217ZYWWqdthryRQ9YPsNIlsGujqZEaiRWN/YjuOONYgqhvwYOMqG0vHro3wcR0GJtNklkIrnmAdvtZLIyB7/NI= 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=wJ8w88xb; 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 Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-1d5b60c929bso20521875ad.3 for ; Fri, 09 Feb 2024 14:07:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707516474; x=1708121274; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=XgDgnWq7Lrk26+EQn5hdWDLpi21lwuFWEvrXKhI43Hc=; b=wJ8w88xbGhAtr7vGZJqu9gAFcNp7X+fk/+L6Doyx5AU620NT3lzrG3aETdT9GvxYLG 05NefKGxb1bLS0H40NQvkLjZBvDXy4d+LvpFxfPh+QOea2ileP99nykEnk7XkV9yy6t2 US5SlxqHa14yMnpgkg0IPif1kUXpKj6Ufzinu6oZ7KTQrNkOQgoMWdwIFZfWJSZdAp8w yLm90SWo/sq3+ES5nQK6o1COqxggIRkfz1noENi9+4O6Bhe7vzwr7MYtoYJGUeUUnmPt X0W9AAC0ZJXASj+L5rHeUEEQYos8wBDaO+i/P2djkoeDYpKWv2FAmvHXhfep5rC+p3Hr VnJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707516474; x=1708121274; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XgDgnWq7Lrk26+EQn5hdWDLpi21lwuFWEvrXKhI43Hc=; b=iGBMRS45bX+GaRyu7q55ukZhiaf7CpnMlZED5WUFaXqnPvO9O59ymXER9U3W2zl2qH ma/iB3IRvQ/9EBGZSHt8prYeOUcJIZ5ZG1AYt2VguDumHILZo7lW28asziWQzxCcrf+Z 2LSRQWtB9LpzQKuyozsjLUfNHPOt5fjkx4g9r4pHk5WUOe3T5SAL24Tvf25Yn4TM3NLG 6SRVDnjBb8W//wFmPSkXDof2F+X+SVwkpPb3qW1zKGtwF90z+QKch5Afhfl6Ve8C3Acu E1b42Bw2AUBVGN/pPsOu9ci07FeT+xNEi0zZh4K8fxNP8cc8xlCql8PJQtZdOQVYHg3l tfvQ== X-Gm-Message-State: AOJu0YwRmjkeOkS6GYNFx6yJ5CFO7/605FRwZJ/+6mOgJpYSER+42um5 XaG3L/AbNcKpDMw1rADCenApcrdxqecp8qkepZXHqcJR+Lr+5mi6pj6GhTIHnCrsxF5QadSrXgp b6Q== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:e494:b0:1d9:6e09:dd3c with SMTP id i20-20020a170902e49400b001d96e09dd3cmr1378ple.13.1707516473822; Fri, 09 Feb 2024 14:07:53 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 9 Feb 2024 14:07:50 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240209220752.388160-1-seanjc@google.com> Subject: [PATCH 0/2] KVM: x86: Cleanup kvm_get_dr() usage From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Mathias Krause X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790462096076322766 X-GMAIL-MSGID: 1790462096076322766 Make kvm_get_dr() use an actual return instead of a void return with an output, which led to a _lot_ of ugly code, and then open code all direct reads to DR6 and DR7, as KVM has a goofy mix of some flows open coding reads and some flows bouncing through kvm_get_dr(). Sean Christopherson (2): KVM: x86: Make kvm_get_dr() return a value, not use an out parameter KVM: x86: Open code all direct reads to guest DR6 and DR7 arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/emulate.c | 17 ++++------------- arch/x86/kvm/kvm_emulate.h | 2 +- arch/x86/kvm/smm.c | 15 ++++----------- arch/x86/kvm/svm/svm.c | 7 ++----- arch/x86/kvm/vmx/nested.c | 2 +- arch/x86/kvm/vmx/vmx.c | 5 +---- arch/x86/kvm/x86.c | 20 +++++++------------- 8 files changed, 21 insertions(+), 49 deletions(-) base-commit: 873eef46b33c86be414d60bd00390e64fc0f006f