From patchwork Fri Feb 17 19:33:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Krause X-Patchwork-Id: 13145196 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0586AC64ED6 for ; Fri, 17 Feb 2023 19:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229819AbjBQTbb (ORCPT ); Fri, 17 Feb 2023 14:31:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbjBQTbZ (ORCPT ); Fri, 17 Feb 2023 14:31:25 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ABE85D3EB for ; Fri, 17 Feb 2023 11:31:21 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id t6-20020a7bc3c6000000b003dc57ea0dfeso1694679wmj.0 for ; Fri, 17 Feb 2023 11:31:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grsecurity.net; s=grsec; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h3qVJ0bF2LOwR9FYE4JKJYonbraLFt3EzjvQr+HEt5I=; b=dDJnTYwngnWaEMzbUx4jZ16owZ0sQuT5enltrUeDwvsRnZTa0ZqUFeznb/4baviObx t+mRuQUNzNKeXtRe6pvoANi8rM4kQ1odHY5y1ACKAT+zWtZg1GxPJ9SsvSdrd2Bs3cVo kDmttHlvLfsqIbJnP3hg9dd7/QuOc/Kuz/qnGqK0bFNL7941EHNQvJmPy7y1fs9wHlTX 5QvSWkqXB3S5gJWtQpNUDA0cb2n4FIAKZhGtB9j0JrS/VVVCORkenW0VV/qAPT08cQKC BVPZn/LC+cnMNSfeAJCYI1xsgmJz3h24QGAileaI9c17I7NU66LYjfXA3IYX49EWP0LI Jzmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h3qVJ0bF2LOwR9FYE4JKJYonbraLFt3EzjvQr+HEt5I=; b=Uv646cOD7a22S0pjbvbHgDemOpNmZdDhGuD+eYeliIGytM/jhar2RASuyPlav3JwEl ebPGqE2NA+StxBhiFOolevxnrkClLd8+ahj6xb+KGOPOPo8A+c85P7vWDqM9kAAzJ4NG u5EhgjtxdZTANcoiYCIENuFW3lY2j1eMX9MfRC3tPbEXTz9O0w9Uam9XSg9VDXpwTeaQ 5dStjWy75SLW5/9qFFZg7es73sqUL3vt6dFmGDyAnPozCWg9U6SAnuT7qX4TZFiDbv9M Hi8D6uQwn4jC6rxsSXXeWN+6VdEngcXgTEswpzouXi4/HnUtH4td99ScIFRdZQmyFmlb KFiA== X-Gm-Message-State: AO0yUKW4mm8BrFSO9lqC86fU+I0KY0c5rMDvfgLLyTvoTtFbP36DUKqF 2qM1tb7z9pPfCMscDY+UKasM1NtO7dTSKRXC X-Google-Smtp-Source: AK7set9FnlK5idA3iZnITZZN8lHm8p4XAS8BntZScEnhgNS2QLM37gJ5WgbduUThKUAlYlTQOqBLSg== X-Received: by 2002:a05:600c:180a:b0:3db:1434:c51a with SMTP id n10-20020a05600c180a00b003db1434c51amr1329698wmp.40.1676662279691; Fri, 17 Feb 2023 11:31:19 -0800 (PST) Received: from nuc.fritz.box (p200300f6af465a00bfa0a0965e5e0d85.dip0.t-ipconnect.de. [2003:f6:af46:5a00:bfa0:a096:5e5e:d85]) by smtp.gmail.com with ESMTPSA id u9-20020a05600c4d0900b003e1f2e43a1csm5393618wmp.48.2023.02.17.11.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 11:31:19 -0800 (PST) From: Mathias Krause To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Mathias Krause Subject: [PATCH v2 1/2] KVM: x86: Shrink struct kvm_pmu Date: Fri, 17 Feb 2023 20:33:35 +0100 Message-Id: <20230217193336.15278-2-minipli@grsecurity.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230217193336.15278-1-minipli@grsecurity.net> References: <20230217193336.15278-1-minipli@grsecurity.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Move the 'version' member to the beginning of the structure to reuse an existing hole instead of introducing another one. This allows us to save 8 bytes for 64 bit builds. Signed-off-by: Mathias Krause --- arch/x86/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 6aaae18f1854..43329c60a6b5 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -516,6 +516,7 @@ struct kvm_pmc { #define KVM_PMC_MAX_FIXED 3 #define KVM_AMD_PMC_MAX_GENERIC 6 struct kvm_pmu { + u8 version; unsigned nr_arch_gp_counters; unsigned nr_arch_fixed_counters; unsigned available_event_types; @@ -528,7 +529,6 @@ struct kvm_pmu { u64 global_ovf_ctrl_mask; u64 reserved_bits; u64 raw_event_mask; - u8 version; struct kvm_pmc gp_counters[KVM_INTEL_PMC_MAX_GENERIC]; struct kvm_pmc fixed_counters[KVM_PMC_MAX_FIXED]; struct irq_work irq_work; From patchwork Fri Feb 17 19:33:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Krause X-Patchwork-Id: 13145195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECD73C636D7 for ; Fri, 17 Feb 2023 19:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229831AbjBQTbc (ORCPT ); Fri, 17 Feb 2023 14:31:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbjBQTbZ (ORCPT ); Fri, 17 Feb 2023 14:31:25 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46F9A5CF04 for ; Fri, 17 Feb 2023 11:31:22 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id e4-20020a05600c4e4400b003dc4050c94aso1677944wmq.4 for ; Fri, 17 Feb 2023 11:31:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grsecurity.net; s=grsec; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8WSi6Yx8V8miujoCWlAIYCoROXEDMV4nQFAEHjGFqXc=; b=XaN+ZS6Q0gwXJELjlZ+dXx1Lg5XiD31tdHIYvcm2zbyWkJvBP6Ke7uBtdkGFnsTbh7 uRcsX3lNYZlv1u4Emwj1XXhlPVVh/hs6HYrmhqgJUnLDsd0OyJ2gzXuErd8uu4c4T8I7 XXuTyeEn7ps1KYwLMWmYjdQrX4nCDDqsHL1hduYTD7w7sZYe1Ynb/A6NxvmS1lPXxf8A SXGlJR9OJ0+cZJmvRLpAcn5lo4EQUV1hfQjWsmqRo9jQKIhYAyKsVjm1k8q4PJwYnrwX iAQxLB4LckyhDXZGQ2Koxo9W0W8g0A4xMLJdbYxqVbqU5xuJ0YpAG6eJ7q7AP3n+BBxN a/tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8WSi6Yx8V8miujoCWlAIYCoROXEDMV4nQFAEHjGFqXc=; b=uDYbr64+Na9J2IhHNqzIDMXPuTWJz2YZN0bvdxds+Vsecbwx1WL3AB8k3q/YozG9bv kfCjxFjXDFJbnLaC+BemsfcBeA2Tg5pyspLl/SQaGb6GhNzfOGXrv1my0BL0q2cgYMSA uAI7KH9CuhKTIltCh5CmzSYpe9bXW/4eu080A4wf2auRidGlWFP7A+HLTusQOkNTU7Pj Hm55hARZknszURGBPLy2WO2Tw53VfSzerUZEYL5/uJoUkZZK3q5XcApYQVF0AiZfqojS wSo67jorsNf2ENgIKhaoC2eWgIEu3/8/EiyzTRwXVdvas1NHpQdw2cZbZAzedjL1aoVN zshg== X-Gm-Message-State: AO0yUKUelVa9ddxay1j1U16cEWCYes7D3jGuB0EHH75aIe+UpVdCkEWG bxkYaTo/Dd/fPbvXtDRoOdX9FnpqPSKsd8j4 X-Google-Smtp-Source: AK7set9mBhbjWBQbVXwnRMh3ycSCnEMS4xykCEJmmL33SAA6mM/Q6hcBqqlF1TY/TdH9naEH7RQ2/w== X-Received: by 2002:a05:600c:3297:b0:3e2:1368:e395 with SMTP id t23-20020a05600c329700b003e21368e395mr5115275wmp.33.1676662280398; Fri, 17 Feb 2023 11:31:20 -0800 (PST) Received: from nuc.fritz.box (p200300f6af465a00bfa0a0965e5e0d85.dip0.t-ipconnect.de. [2003:f6:af46:5a00:bfa0:a096:5e5e:d85]) by smtp.gmail.com with ESMTPSA id u9-20020a05600c4d0900b003e1f2e43a1csm5393618wmp.48.2023.02.17.11.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 11:31:20 -0800 (PST) From: Mathias Krause To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Mathias Krause Subject: [PATCH v2 2/2] KVM: Shrink struct kvm_mmu_memory_cache Date: Fri, 17 Feb 2023 20:33:36 +0100 Message-Id: <20230217193336.15278-3-minipli@grsecurity.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230217193336.15278-1-minipli@grsecurity.net> References: <20230217193336.15278-1-minipli@grsecurity.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Move the 'capacity' member around to make use of the padding hole on 64 bit systems instead of introducing yet another one. This allows us to save 8 bytes per instance for 64 bit builds of which, e.g., x86's struct kvm_vcpu_arch has a few. Signed-off-by: Mathias Krause --- v2: use order as suggested by Sean include/linux/kvm_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h index 76de36e56cdf..0b2ddce47f11 100644 --- a/include/linux/kvm_types.h +++ b/include/linux/kvm_types.h @@ -91,11 +91,11 @@ struct gfn_to_pfn_cache { * is topped up (__kvm_mmu_topup_memory_cache()). */ struct kvm_mmu_memory_cache { - int nobjs; gfp_t gfp_zero; gfp_t gfp_custom; struct kmem_cache *kmem_cache; int capacity; + int nobjs; void **objects; }; #endif