Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5699821pxb; Mon, 28 Mar 2022 16:24:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzels4V026cxbto4FOhFwrQ8vI/u2Gl5tTbvWeCOAGiKpGKqdGsmfVMghn1l4gQL5XKbIrp X-Received: by 2002:a17:90a:e7ce:b0:1c7:bf82:27c0 with SMTP id kb14-20020a17090ae7ce00b001c7bf8227c0mr1483610pjb.88.1648509843277; Mon, 28 Mar 2022 16:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648509843; cv=none; d=google.com; s=arc-20160816; b=VtZdxOjTo1gxCL5wgL4Xy+vIh8r08KWKsiEMqg9klVaDkqqZF18C75jhyZDM36u5sr 9r4zVF+W5/f3IGZhuMsEMZWDJmsjQm++LLS1FiBFmOj9B/roTvCqbHEkQJBlLzv72jot NBfWo7vsfg/xJjaJgzQocvlqGk3fScFehYMfH7WK+iWJvglFCidXLAfNdAFvseEuKMkR CzWvgmq9LpyTDBEG2fF2DWORTfFiTRRPlz1NcYLDn9jDYChKxHflVTOeSe2qP5q0T2u5 z6ha8ZNDm/SgLtNvQD29Xp24OrQRBjltQXUigz1hl7Y06hivAePma9hhStY3qGWlu6l0 a90w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=oYCH6Tbs6UcHw4KzVWnqyB1tic3vYPe5BOmHRgVgeGc=; b=isFEas2CLHgQbPqah7OLYWCycqcrgu5YhDqaWEObSYkFXUS70dKNlzRhjZMjz3sFrf r+ku+QY00hNgv4S5piKR37OUimLDHO1ETamARInx6AyjuYv42qnHcqlgK0ioOlKDgBo7 aQOywi+afk9p169MU0XtaXI06lx2m74eVJQP+iE3Mwqo2ZiNIOLCpt9iOO5tRkF9jW74 tG4ATs4PgShWQGauh8sHftvWhrKUG2pSCniYSLZnnm1Si305TysfgsrvG9lzdsLpYbV4 5NM6WwlQoK2R/zIjgD+wrKsuremI/ayLVOXokf6C2YisK2aCcsygov7KnpjR9igwOfFr imzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=DXMddp8E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s19-20020a170902a51300b00153b2d16424si13901827plq.44.2022.03.28.16.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 16:24:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=DXMddp8E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B8E0D78FFD; Mon, 28 Mar 2022 15:41:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229987AbiC1WnS (ORCPT + 99 others); Mon, 28 Mar 2022 18:43:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbiC1WnL (ORCPT ); Mon, 28 Mar 2022 18:43:11 -0400 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E7A95DE7D for ; Mon, 28 Mar 2022 15:41:30 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-2e5e176e1b6so165099237b3.13 for ; Mon, 28 Mar 2022 15:41:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oYCH6Tbs6UcHw4KzVWnqyB1tic3vYPe5BOmHRgVgeGc=; b=DXMddp8E6FufRbI7n5Mavm/b4sDlNGwYT7SziIoihbl7tK7WJf2VlYhXskH/Lotqxw varDp4naHpHQRsmUWhXkzmBOR7a7R9a176GfXY3o7xQbejLy19s+q+erD9NXDpcxObqV maBZvTQCN+RdX5ppq0tht/ip46gP3e8Qp4Odw8a/DSGU6LthwR6TMI2zcxwOvhrUWzYr WyHvsvcNdMtX023I/zWUxPAbnqUZpVomxEqS9C83U1JnXsEBNw89KUTu8gDyGWJfwPWB nKT0gCELCe0m5MhqA4TVxR9TZ585fhUs8KQ7Nwr1vwoOD2pD+TL+YIuzOWg0xyk+c8ik zoBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oYCH6Tbs6UcHw4KzVWnqyB1tic3vYPe5BOmHRgVgeGc=; b=Wb044hrueqrlQFrL2KxjMp+954/0xOiSx36JZHryoiNscOtSiO4CfDKRlxd61xhkYB Lpgpqnwk3rofO2Z57QY46FJERWahpBOL5BDFlZk3qe0+VWnZVVqMlgQsCNG4IW1cZ/cv bpzHPtGLgYTCVsDvOLIu51fJbQ++C9Of0O9lPG1pwIAvH4OSbDZLPTl5FHqNeRX5Q+P+ 0DjwMAekcYVcyjcUn6VWHszQaJdwelVjAk47kWJuIuv/lY/cg6nM+R6CiGSo8pR5EAoF dflfAKyhxn9UQben7i55P+tJ8QAokPuBI0zoJKlgRcLzmVwls7ET5BHvSBG/3zOTUPa2 z7jA== X-Gm-Message-State: AOAM533bcFTObGP0HhLIfLNNAZhf/eVvE796bibXNzy1PcMK86Tv6n1u tv3U7N0z/k/F04LIFjsj0yXQWl1Ixk5JTgE50kKurQ== X-Received: by 2002:a81:15ce:0:b0:2e5:e189:7366 with SMTP id 197-20020a8115ce000000b002e5e1897366mr28596553ywv.188.1648507289066; Mon, 28 Mar 2022 15:41:29 -0700 (PDT) MIME-Version: 1.0 References: <20220321234844.1543161-1-bgardon@google.com> <20220321234844.1543161-8-bgardon@google.com> In-Reply-To: From: Ben Gardon Date: Mon, 28 Mar 2022 15:41:18 -0700 Message-ID: Subject: Re: [PATCH v2 07/11] KVM: x86/MMU: Factor out updating NX hugepages state for a VM To: David Matlack Cc: LKML , kvm , Paolo Bonzini , Peter Xu , Sean Christopherson , Jim Mattson , David Dunn , Jing Zhang , Junaid Shahid Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 28, 2022 at 1:18 PM David Matlack wrote: > > On Mon, Mar 21, 2022 at 04:48:40PM -0700, Ben Gardon wrote: > > Factor out the code to update the NX hugepages state for an individual > > VM. This will be expanded in future commits to allow per-VM control of > > Nx hugepages. > > > > No functional change intended. > > > > Signed-off-by: Ben Gardon > > --- > > arch/x86/kvm/mmu/mmu.c | 18 +++++++++++------- > > 1 file changed, 11 insertions(+), 7 deletions(-) > > > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > > index 3b8da8b0745e..1b59b56642f1 100644 > > --- a/arch/x86/kvm/mmu/mmu.c > > +++ b/arch/x86/kvm/mmu/mmu.c > > @@ -6195,6 +6195,15 @@ static void __set_nx_huge_pages(bool val) > > nx_huge_pages = itlb_multihit_kvm_mitigation = val; > > } > > > > +static int kvm_update_nx_huge_pages(struct kvm *kvm) > > +{ > > + mutex_lock(&kvm->slots_lock); > > + kvm_mmu_zap_all_fast(kvm); > > + mutex_unlock(&kvm->slots_lock); > > + > > + wake_up_process(kvm->arch.nx_lpage_recovery_thread); > > +} > > + > > static int set_nx_huge_pages(const char *val, const struct kernel_param *kp) > > { > > bool old_val = nx_huge_pages; > > @@ -6217,13 +6226,8 @@ static int set_nx_huge_pages(const char *val, const struct kernel_param *kp) > > > > mutex_lock(&kvm_lock); > > > > nit: This blank line is asymmetrical with mutex_unlock(). > > > - list_for_each_entry(kvm, &vm_list, vm_list) { > > - mutex_lock(&kvm->slots_lock); > > - kvm_mmu_zap_all_fast(kvm); > > - mutex_unlock(&kvm->slots_lock); > > - > > - wake_up_process(kvm->arch.nx_lpage_recovery_thread); > > - } > > + list_for_each_entry(kvm, &vm_list, vm_list) > > + kvm_set_nx_huge_pages(kvm); > > This should be kvm_update_nx_huge_pages() right? Oh woops, duh. Apparently I did not compile-test this patch individually. > > > mutex_unlock(&kvm_lock); > > } > > > > -- > > 2.35.1.894.gb6a874cedc-goog > >