Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp564429lql; Mon, 11 Mar 2024 10:25:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUu4EnqPFEnio04f1hWfo7dPKiLOzoxF5MRCdv0HTm4JL6qg5VmONPR3doL5zJrXoRoghdE4FJ5GrQ33P1d5aa8xLCRJTd0iV7vIosHLg== X-Google-Smtp-Source: AGHT+IGr2mEW4oykKEHBtilPx9bAFykcAY1brN6SKEKm5l4ciTVhePJ0UJHJF2u4XBPN+ZfWNtda X-Received: by 2002:a17:903:184:b0:1dc:abeb:22fe with SMTP id z4-20020a170903018400b001dcabeb22femr8192305plg.65.1710177923618; Mon, 11 Mar 2024 10:25:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710177923; cv=pass; d=google.com; s=arc-20160816; b=BVGLRWX+ztOHFpZV0SJho2SWvVVEn6XtKEhuonjBmd2ghqVage48T0OOZXhvvNb+FJ RrH7QwvvnggmaadNDpKS6fUZ9BHT/vXX1ImA507esz/bHu/sG0S/j+ndZYhHLmK1MIK5 vbkmlSpacyNmHUfP/bpFCJXMdH0xAnETf1rXcaLfb5CaBPY3TKUQoFly6hpMqaNFbZcC jp4xJDFzBjkPkINcfqFKCxFF6U1jcO9eRlcKxRMF4FN6YmUKbl4XacMCcZPjjXJspQnx U6WU1tlVP8ZHJO/OAX0V2UEUtgpcazhzgW/OeOLL24QjNTzSOKuqQ5ga1kuZkECx10IN 4PIg== 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 :dkim-signature; bh=UmZfmbMNljhd7xsF5ugG1U7e5cDaKYSiE/Ydm7nW5VY=; fh=sbbx1g0bBzS/udrmfkj0qBGL/q8pYDvup3/MJQdQiNw=; b=fTDQCSoujKqwYmzIy3WH+GmJv83ym9LeSvGGRuvUJSLKfcPzEbBffG1ARS+QCEx8Os lvSEUhUVLt/dBs7keh4GEp3HKLX7ooEvLCyD6gFRBr4Xw2i2+0ENOESPIN4EkxZMuVIm fG8aBni0gp/gMjwCqAHMYiPMnAMhX2fiquGIvvU547RTtobagZKT+H4pQnxF9wrrRRL3 g+1QwzmXWaUDl+rDoMw/BWtbz4bl17qgPXTTt/b2dQpK5l2O7w3/0epCfuWaMPytZNvo XuxfSrhYRdnz1wOhp+DVxnzL6Lghw6rrnJjicXNuBx9FWK16nIUHRRU2+wBJyrtlglX5 nt3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1WKsd2Za; 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-99302-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99302-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. [147.75.48.161]) by mx.google.com with ESMTPS id k12-20020a170902c40c00b001dcad9d9e7dsi5567650plk.576.2024.03.11.10.25.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 10:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99302-linux.lists.archive=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=1WKsd2Za; 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-99302-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99302-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 1D2A2B212D8 for ; Mon, 11 Mar 2024 17:25:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3059B5336F; Mon, 11 Mar 2024 17:24:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="1WKsd2Za" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 E2BD7524AA for ; Mon, 11 Mar 2024 17:24:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710177894; cv=none; b=pNkOwfMaFX/o6fAAr7lXo61hXMm1XYsn1UefQRDg5ELkUNk1yzgdIGVlIE4HandcS+6LeIpwDxhzoxtzU+9WXwMAiVImXKj60CC1t2sS0P88FSdSSyuxVRlH6tF7TbGFhAJeIpjTjtZCZPb0+PDYyzhP1D0dQoU1z6xNg4a9t5A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710177894; c=relaxed/simple; bh=XWEi7LHXquSIEQW89Dhsaa+W0TGVTzrGxEyKMs1bzG4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=HZrZ0u6KEZmbw1rZVLK8CO7KQP02KZxSiTBheGqjlS9n1ItGdTlTq2/p2nL8FTR676pEnKfFxR4AB7SDGCvNeGO3t7j2vb3U1xLPh3J09ePJX2+YkzCsL7OYzSPptLRmUycudT5R7KIgDxkAufJFm+NIjbIPjOL6zVPH/cVbT00= 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=1WKsd2Za; arc=none smtp.client-ip=209.85.219.201 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-f201.google.com with SMTP id 3f1490d57ef6-dc6b26783b4so3985020276.0 for ; Mon, 11 Mar 2024 10:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710177892; x=1710782692; 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=UmZfmbMNljhd7xsF5ugG1U7e5cDaKYSiE/Ydm7nW5VY=; b=1WKsd2Zadb2P7qkoBWxQ8e6ubhBzBjbK+mJ+ra/wHpq0aMhuYFw0IR+psLxXgmJ4h5 5dqU4/oF7BN91pHLZULM6uvyjkwMUtZn+i0tlfwM3iYCjP9VL/R9Y/mnx5RPtzkSbzwm P6MVSYNB0kbnkvQcbDQU+JhSlP9+FfO5d4hsgp7PyK0csYG0Kozoeny5fYrrCB6rjjFM TFqgYQdMYHLkBLT3uYVvurtGYOEjRKSHPQNQao/D6vwz+xpfiEnAxeBKl9oU7JklQSTT 7r/H0U9gArmGsVDFzFwgRoeJrJZdOLJRsVykhx76TUBVxi04vtMP8B+4dJaYbOBATKgO JdLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710177892; x=1710782692; 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=UmZfmbMNljhd7xsF5ugG1U7e5cDaKYSiE/Ydm7nW5VY=; b=LEh+nG75LjRP+0jzsxx+XFXXTCKFyqnGFipEp1AzBnQMnZCgQtYhrt8y8YnHirW3AR OU9b1fOFz1GzHYuDhrBqXvHBAVlFU/YIVg17BUKw2IJzvlOYXRu5xmlG84UOLxFoxKNm uKpVxvjdgWF8lUZj/h41Zmk9kgM/AQ6FHENDPxFql7jVKRm8Q8cEPj/TC+teY+B3cb32 z6hBXUnSPat3qR7Ii/0/aR9Q8ydY5OwCG68drSgFHUfYRLHbgw0oMTXqONUo4vvnA2w5 oUmbVTKLiR+TwlLBgrReOE2BJDz2pbn+mQj4LaUy0r1w7DCHTRJ7ggodiUh1lpHJIkWn ZsIw== X-Forwarded-Encrypted: i=1; AJvYcCVGHGsaZc1QGczscGUE1ipqbvJm2PBJGpPjes1T4/jbtUuIp1IbQbIM6xc4TAVrbEJQANBI/j7G6BXUqWltGOwcQEmipjls9qQtaNJI X-Gm-Message-State: AOJu0YxQ7SGD3z1FuF8GlDI8UwVPx4UUbaXvAnqmLubYM8PWd53OFX62 xmTjsgPm8WYwBDIP+A8XnHObc7yRzKmGpzhZKYEiWzgUsXYxvkMtR3X3BhC7ZYyBukqnnxPuhpQ d1g== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:18cc:b0:dc7:82ba:ba6e with SMTP id ck12-20020a05690218cc00b00dc782baba6emr389686ybb.7.1710177891972; Mon, 11 Mar 2024 10:24:51 -0700 (PDT) Date: Mon, 11 Mar 2024 10:24:50 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: Message-ID: Subject: Re: [RFC PATCH 3/8] KVM: x86/mmu: Introduce initialier macro for struct kvm_page_fault From: Sean Christopherson To: isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, isaku.yamahata@gmail.com, linux-kernel@vger.kernel.org, Paolo Bonzini , Michael Roth , David Matlack , Federico Parola Content-Type: text/plain; charset="us-ascii" On Fri, Mar 01, 2024, isaku.yamahata@intel.com wrote: > From: Isaku Yamahata > > Another function will initialize struct kvm_page_fault. Add initializer > macro to unify the big struct initialization. > > No functional change intended. > > Signed-off-by: Isaku Yamahata > --- > arch/x86/kvm/mmu/mmu_internal.h | 44 +++++++++++++++++++-------------- > 1 file changed, 26 insertions(+), 18 deletions(-) > > diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h > index 0669a8a668ca..72ef09fc9322 100644 > --- a/arch/x86/kvm/mmu/mmu_internal.h > +++ b/arch/x86/kvm/mmu/mmu_internal.h > @@ -279,27 +279,35 @@ enum { > RET_PF_SPURIOUS, > }; > > +#define KVM_PAGE_FAULT_INIT(_vcpu, _cr2_or_gpa, _err, _prefetch, _max_level) { \ > + .addr = (_cr2_or_gpa), \ > + .error_code = (_err), \ > + .exec = (_err) & PFERR_FETCH_MASK, \ > + .write = (_err) & PFERR_WRITE_MASK, \ > + .present = (_err) & PFERR_PRESENT_MASK, \ > + .rsvd = (_err) & PFERR_RSVD_MASK, \ > + .user = (_err) & PFERR_USER_MASK, \ > + .prefetch = (_prefetch), \ > + .is_tdp = \ > + likely((_vcpu)->arch.mmu->page_fault == kvm_tdp_page_fault), \ > + .nx_huge_page_workaround_enabled = \ > + is_nx_huge_page_enabled((_vcpu)->kvm), \ > + \ > + .max_level = (_max_level), \ > + .req_level = PG_LEVEL_4K, \ > + .goal_level = PG_LEVEL_4K, \ > + .is_private = \ > + kvm_mem_is_private((_vcpu)->kvm, (_cr2_or_gpa) >> PAGE_SHIFT), \ > + \ > + .pfn = KVM_PFN_ERR_FAULT, \ > + .hva = KVM_HVA_ERR_BAD, } > + Oof, no. I would much rather refactor kvm_mmu_do_page_fault() as needed than have to maintain a macro like this.