Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10782429rwp; Fri, 21 Jul 2023 05:04:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlERC2Ju6yjw8cDVyGEGrFcPISZ39RsqnELxlt8Qbsm9f5wtc8P9uHzbylCsf0TETtg+TLuu X-Received: by 2002:a17:906:3f56:b0:99b:55e3:bbd with SMTP id f22-20020a1709063f5600b0099b55e30bbdmr1298721ejj.34.1689941091662; Fri, 21 Jul 2023 05:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689941091; cv=none; d=google.com; s=arc-20160816; b=nTF3VBQdPl4+6lsUVPE0xjyhTVM7UP0wvT6wO8VJw6pbXJ7pOtWVWH1jNgQIUccJWt UiUNbO7XHAC0bs/5YHk3n496WOajE86MmtGy+6hbgY0dUlSxl2LMLF0ggs+gx2436m4a zPQAgnN1edFU6PdFVdjb3/+Gx9mZn7qb17ImgVWGVCY8/WqUkVPHv8GOxR4LarF3gsdQ Sz9v/OORtBUIvao3xnNUBEyw6nYq5t3oixNGCWnD7LRy3zqnUI1AvTcA0CD0CCzMMecu 4iqMD4XIGzSm0S6D0UVDTzydqAieutQH9Z2SkpuSXSsdgeR/OUNkLkDEZbCKWaNlHT8S zbpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=4Y7rbnaDJbn/YejSF4mQVA8Z4grlfMZHjKPnDFxLZ8A=; fh=Ha0fK0q/QRDhu63ZqG+O6WFFibL7W0Vai9siCdqdoHU=; b=ccOHLWPfOv/aKnxqxtKHKxD9V4/lIZrEZ3LauvcG47bwQ6gdXSBUJy4Mh0+ZGMTbMm BHL57LdsYnObZW1kPeM5UPH5a+TJJ5sqXthf0+g5RLIcubRpt+Eg6ECCtXFc/1VLlGWQ o/7oy71amiLLM6sr1W5KMphBg5mDwol71jjHOu6VQe4ZW1QxNpruVnZa6X+B1WzLayRt 7C5dTaZ/5D+zXLsTZ23+o5Zj0X5Cyl8sr1uIr1d8Rq8nGBdd7znGLTZaFRuETBH3Wrkj iDUTt4BvFmug39+wkx7+MMy4JgnPeFmBwS/L3DDinSr+wDbh2cUFL68/qiNTYKYUuoGO Q8Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="NLYxJ/tI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a17090606c100b00993320628absi2215574ejb.675.2023.07.21.05.04.24; Fri, 21 Jul 2023 05:04:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="NLYxJ/tI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229927AbjGUMA1 (ORCPT + 99 others); Fri, 21 Jul 2023 08:00:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbjGUMAZ (ORCPT ); Fri, 21 Jul 2023 08:00:25 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58BF819B2 for ; Fri, 21 Jul 2023 04:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689940782; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4Y7rbnaDJbn/YejSF4mQVA8Z4grlfMZHjKPnDFxLZ8A=; b=NLYxJ/tI375ddfrYE69u4PU4Z9h7i6tOguCLsIe+/EncQBl2Aqsf93Gj2dpLFHHmIJWLvd wEHK9+sHYSWQpfB86rX4TB+P5e6nKB+99bnGoy9jC96Rwt1F2pOlKeFgF426rwViuud1tV rJFa43qXP2DG3tN66TNOfIOxNbBopgE= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-An_sCdLSOEuL5Hkflve6UA-1; Fri, 21 Jul 2023 07:59:41 -0400 X-MC-Unique: An_sCdLSOEuL5Hkflve6UA-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-993d7ca4607so118760966b.1 for ; Fri, 21 Jul 2023 04:59:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689940780; x=1690545580; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4Y7rbnaDJbn/YejSF4mQVA8Z4grlfMZHjKPnDFxLZ8A=; b=Zyp8PDuVGV3FSIifCiVV9NUV4ESPELVosJg6xI6nzy5Gte+hwE9OVK+ZKhY6evSRHW i47iOigTdwnV8uuIPU3ujCuWYLGhURzx5nNZBUNW9kQRkj3ljqt5N5WSA5lrqpRcgEX5 DRCJ9vcX5nqT5DHqyPfazdmZjX1S+aNdq8iplEO+I+4EiSukI9PjigAFDhg+SuNc6+Cb a4J+6bp50lp7eRpeIiyjwd7rxsZ3RmT7bwlLnwRBx80tKZAFWmSwVbEDKZE8DTcgksRB z39eadj6lxqDGxc652JYOFOdQ9m5pz1abSMxfEu6KC70w8AZSA5+LRa6JS10Zc28YYO5 U/LA== X-Gm-Message-State: ABy/qLZWsYaRQS+tQGOWYDXksCaUw2LIjRUCwd3+FIi79NY/OYk2rzFX ZsCTkSGfhs03G4uzYAEw1hhvyq0I/SF0Tb/mNOkdavhE59+XkG8+E6JaLliZNToM3OGRZWBaQFg zwbwVH++kdqaeRZxtevJSZlvc X-Received: by 2002:a17:906:2da:b0:994:54af:e282 with SMTP id 26-20020a17090602da00b0099454afe282mr1360612ejk.10.1689940779997; Fri, 21 Jul 2023 04:59:39 -0700 (PDT) X-Received: by 2002:a17:906:2da:b0:994:54af:e282 with SMTP id 26-20020a17090602da00b0099454afe282mr1360600ejk.10.1689940779630; Fri, 21 Jul 2023 04:59:39 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:9af8:e5f5:7516:fa89? ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.googlemail.com with ESMTPSA id um15-20020a170906cf8f00b00992b3ea1ee3sm2078970ejb.159.2023.07.21.04.59.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Jul 2023 04:59:38 -0700 (PDT) Message-ID: <6118063e-5c91-acc4-129f-3bacc19f25ce@redhat.com> Date: Fri, 21 Jul 2023 13:59:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [RFC PATCH v11 09/29] KVM: x86: Disallow hugepages when memory attributes are mixed Content-Language: en-US To: Sean Christopherson , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Peng , Fuad Tabba , Jarkko Sakkinen , Yu Zhang , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , Vlastimil Babka , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" References: <20230718234512.1690985-1-seanjc@google.com> <20230718234512.1690985-10-seanjc@google.com> From: Paolo Bonzini In-Reply-To: <20230718234512.1690985-10-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 7/19/23 01:44, Sean Christopherson wrote: > +static bool range_has_attrs(struct kvm *kvm, gfn_t start, gfn_t end, > + unsigned long attrs) > +{ > + XA_STATE(xas, &kvm->mem_attr_array, start); > + unsigned long index; > + bool has_attrs; > + void *entry; > + > + rcu_read_lock(); > + > + if (!attrs) { > + has_attrs = !xas_find(&xas, end); > + goto out; > + } > + > + has_attrs = true; > + for (index = start; index < end; index++) { > + do { > + entry = xas_next(&xas); > + } while (xas_retry(&xas, entry)); > + > + if (xas.xa_index != index || xa_to_value(entry) != attrs) { > + has_attrs = false; > + break; > + } > + } > + > +out: > + rcu_read_unlock(); > + return has_attrs; > +} > + Can you move this function to virt/kvm/kvm_main.c? Thanks, Paolo