Message ID | 20250122152738.1173160-6-tabba@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6B60C02181 for <linux-mm@archiver.kernel.org>; Wed, 22 Jan 2025 15:28:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 671C26B0098; Wed, 22 Jan 2025 10:27:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F9636B0099; Wed, 22 Jan 2025 10:27:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EDED6B009A; Wed, 22 Jan 2025 10:27:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0B6776B0098 for <linux-mm@kvack.org>; Wed, 22 Jan 2025 10:27:55 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B4C041603E7 for <linux-mm@kvack.org>; Wed, 22 Jan 2025 15:27:54 +0000 (UTC) X-FDA: 83035468068.24.1F5ACFE Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf27.hostedemail.com (Postfix) with ESMTP id D0DA44001A for <linux-mm@kvack.org>; Wed, 22 Jan 2025 15:27:52 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3rnVH0T4; spf=pass (imf27.hostedemail.com: domain of 3dw6RZwUKCBwL23328GG8D6.4GEDAFMP-EECN24C.GJ8@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3dw6RZwUKCBwL23328GG8D6.4GEDAFMP-EECN24C.GJ8@flex--tabba.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737559672; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3HB24ys9olZtoFbzLvLFGPKqOLdaE1YgibZ0bUHAkc0=; b=PzeN4AnfbI1sOlSxJ0uZ9au+d86lQ8z7s8WrAfevEaumUEQwzwqI09B9iPbnxj4ht+tftG 18Aaj1aY0B7/4H9Xu8GijTzoJuiUNH3dSvyn1YygZ+2Ac18ucawQbCzqY2SIdlIy/WiJAv N8HNPMHgRXkYn75GrfaXnRrNWFPE78U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737559672; a=rsa-sha256; cv=none; b=WZjaicslwH/deyrojjdunRIfDVWW4aBY/Ol2HU1GRKFkwvVtxh48WDj920O6PFM7vqUdFm SYeK9W9FlUiF7z6Z3iGo4lQsNyFmbjgde9meOlRjylUFzwD9fekxlvrd7R4IQZi5ESJ0Tz J3ntYDMhEe1wQMeC84szkF5Y9g8BzJ8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3rnVH0T4; spf=pass (imf27.hostedemail.com: domain of 3dw6RZwUKCBwL23328GG8D6.4GEDAFMP-EECN24C.GJ8@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3dw6RZwUKCBwL23328GG8D6.4GEDAFMP-EECN24C.GJ8@flex--tabba.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-43625ceae52so38341545e9.0 for <linux-mm@kvack.org>; Wed, 22 Jan 2025 07:27:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737559671; x=1738164471; darn=kvack.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=3HB24ys9olZtoFbzLvLFGPKqOLdaE1YgibZ0bUHAkc0=; b=3rnVH0T4+jzHST3nO2oko+JlilRYkPJl5F9cUSXiV8QF1+Ts36T2o/LvLnc/Njyc9X x0SQEhIjGF8xzPMJ8gMZmKa31ZLfcmWGJLplfo3ehxoAN46gwex6Ajda6AEjqJlb09+F Wvh9a14wlu/3BSFU5dOLgvaVlmyNciT5vpQIDzQM1Z3NNG3FrfOzNIZFpLbRh2wwGWUe pwIvVmJs1SYB2+BXZBpIRfXgGIlSB/unj8OwxtoNy+BgRwPl1n0OdTCuUVwQMFk8cLvF BD8BmS5mimkBUKPqjzzluD7xvLNtfCFrsECvHrNnmooLGPAD3v2+T6HdbeV4DrYuF3X/ daXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737559671; x=1738164471; 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=3HB24ys9olZtoFbzLvLFGPKqOLdaE1YgibZ0bUHAkc0=; b=iG4AuXYkTh+CSMzgMqlB4iu4XlVrKGYUJHOLNmpJnkLqx51YZMiTj+5LgZrXexADCM MRfI57pjhxpa1q+rNm9/rmcjTgImZzQk2rUyXyip6wWmWE69X4TXkcMrq+VYSMC3nkOq M9diSDWmrWE2th/P/+uztRCKW81Df21VAsWg88jxDyF8rfCue0P3f5RLkgC3PvA1IATE ssAcW4E8nClzPGmxKIuMvx4XzxsnibYFGNgHp7M6ScHkzHQieXGix+LX0FZAhKTPb2o/ M2zcn0g1cDMZ06NqcocYj7OoWWg3DSjuevMoDDdBYrdOm2MnhiaVU0D1G/qePaR1THyC YYRA== X-Forwarded-Encrypted: i=1; AJvYcCUGs+lVNj2HTpW2R1YxAt32bAnV3MpM+pKZcmRa4wDQMRlspLzmQdyVYL3RlbxC28ssGhcJpbGo1g==@kvack.org X-Gm-Message-State: AOJu0YwXvyeqMTt2TdpSXXyTb4StD1aR0saD5U2tis3THusBIccbhP33 NbWvTU6pZFpA7c5sisq5RwBDuqHOYB97y1SoHwEwnr2B/rnlNEI28YTPMBupgkgu5xqCcR7vxA= = X-Google-Smtp-Source: AGHT+IGcoJWLBW4MQy/zV2gFico8bxDEFCQzZhOhvpQ0d8FBU2ybuc79Jv0oLXdNK7/4bqI1+6VtomwTiA== X-Received: from wmbjv16.prod.google.com ([2002:a05:600c:5710:b0:436:e723:5be6]) (user=tabba job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:5112:b0:434:a5bc:70fc with SMTP id 5b1f17b1804b1-438913cfa0emr202083105e9.8.1737559671492; Wed, 22 Jan 2025 07:27:51 -0800 (PST) Date: Wed, 22 Jan 2025 15:27:34 +0000 In-Reply-To: <20250122152738.1173160-1-tabba@google.com> Mime-Version: 1.0 References: <20250122152738.1173160-1-tabba@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250122152738.1173160-6-tabba@google.com> Subject: [RFC PATCH v1 5/9] KVM: arm64: Refactor user_mem_abort() calculation of force_pte From: Fuad Tabba <tabba@google.com> To: kvm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mm@kvack.org Cc: pbonzini@redhat.com, chenhuacai@kernel.org, mpe@ellerman.id.au, anup@brainfault.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, seanjc@google.com, viro@zeniv.linux.org.uk, brauner@kernel.org, willy@infradead.org, akpm@linux-foundation.org, xiaoyao.li@intel.com, yilun.xu@intel.com, chao.p.peng@linux.intel.com, jarkko@kernel.org, amoorthy@google.com, dmatlack@google.com, yu.c.zhang@linux.intel.com, isaku.yamahata@intel.com, mic@digikod.net, vbabka@suse.cz, vannapurve@google.com, ackerleytng@google.com, mail@maciej.szmigiero.name, david@redhat.com, michael.roth@amd.com, wei.w.wang@intel.com, liam.merwick@oracle.com, isaku.yamahata@gmail.com, kirill.shutemov@linux.intel.com, suzuki.poulose@arm.com, steven.price@arm.com, quic_eberman@quicinc.com, quic_mnalajal@quicinc.com, quic_tsoni@quicinc.com, quic_svaddagi@quicinc.com, quic_cvanscha@quicinc.com, quic_pderrin@quicinc.com, quic_pheragu@quicinc.com, catalin.marinas@arm.com, james.morse@arm.com, yuzenghui@huawei.com, oliver.upton@linux.dev, maz@kernel.org, will@kernel.org, qperret@google.com, keirf@google.com, roypat@amazon.co.uk, shuah@kernel.org, hch@infradead.org, jgg@nvidia.com, rientjes@google.com, jhubbard@nvidia.com, fvdl@google.com, hughd@google.com, jthoughton@google.com, tabba@google.com Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: D0DA44001A X-Stat-Signature: x9rgq6et5qo8h97x53epzc53pyaon5mi X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1737559672-758530 X-HE-Meta: U2FsdGVkX19aIFShcHTy13DZa9a8k3vPEj+FA06weERxVYqpRx6itsARoEs6ThBxuzqZpoDgJ3oPgttlWR44ejusngIL+0aLnI5PUjV2RVe01gyZb3zpWdiRNK6WKSJrRiVtnggnPgJKR6NP63HZuvu1lUnXN8MXPafeg+VtO35cPZdIGbKt8lFbdWXYkH8B3msHpI9i9qoTiahqy8rzXwy4T2bsJcMhN3SplIF1X9AwtG0+JQ1qWUVH3psMTne3QQnlp+CeEnqmsEcO7ux3Tn5I2bGSo2jjHftU66iLmzBYYNxLfoA13t/EMZ6KZunp8G0zb2iA6lvecgfLIkVh8qufUky9vi2kYl+R9gXGW4Im3SK1EZPVkga3buTPYTY0yRhucFCtMLWjwmEI0A2hyQoh1YvOckgnJ8ilgkPfH92+kVVtr/IDaIwG6R+08Y42FU3BKalL8gbBXm4Amxv7u8pH0ei+nGQtJbG/5TWFGxlKMgp4uE8dR0p77kspIc7URiuEbTsBY62QseGMjoo6L/dtZGmjtnfL+LY1qv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ILq5iWAryd9KrMYNgubOMscuaziA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
KVM: Mapping of guest_memfd at the host and a software protected VM type
|
expand
|
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 342a9bd3848f..9b1921c1a1a0 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1440,7 +1440,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, bool fault_is_perm) { int ret = 0; - bool write_fault, writable, force_pte = false; + bool write_fault, writable; bool exec_fault, mte_allowed; bool device = false, vfio_allow_any_uc = false; unsigned long mmu_seq; @@ -1452,6 +1452,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, gfn_t gfn; kvm_pfn_t pfn; bool logging_active = memslot_is_logging(memslot); + bool force_pte = logging_active; long vma_pagesize, fault_granule; enum kvm_pgtable_prot prot = KVM_PGTABLE_PROT_R; struct kvm_pgtable *pgt; @@ -1497,12 +1498,13 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, * logging_active is guaranteed to never be true for VM_PFNMAP * memslots. */ - if (logging_active) { - force_pte = true; + if (WARN_ON_ONCE(logging_active && (vma->vm_flags & VM_PFNMAP))) + return -EFAULT; + + if (force_pte) vma_shift = PAGE_SHIFT; - } else { + else vma_shift = get_vma_page_shift(vma, hva); - } switch (vma_shift) { #ifndef __PAGETABLE_PMD_FOLDED
To simplify the code and to make the assumptions clearer, refactor user_mem_abort() by immediately setting force_pte to true if logging_active is true. Also, add a check to ensure that the assumption that logging_active is guaranteed to never be true for VM_PFNMAP memslot is true. Signed-off-by: Fuad Tabba <tabba@google.com> --- arch/arm64/kvm/mmu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)