From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC41AC433E0 for ; Thu, 4 Feb 2021 14:53:01 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 76ADF64F4D for ; Thu, 4 Feb 2021 14:53:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76ADF64F4D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C9FBF4B235; Thu, 4 Feb 2021 09:53:00 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2M66JhM2swJl; Thu, 4 Feb 2021 09:52:59 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D29744B23E; Thu, 4 Feb 2021 09:52:59 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 330F54B235 for ; Thu, 4 Feb 2021 09:52:58 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05+dCyppEeXn for ; Thu, 4 Feb 2021 09:52:57 -0500 (EST) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 162464B229 for ; Thu, 4 Feb 2021 09:52:57 -0500 (EST) Received: by mail-wm1-f43.google.com with SMTP id c127so3218026wmf.5 for ; Thu, 04 Feb 2021 06:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GmzDwYCwB3ACF6L8pkrzfaM1KU2/zTHOCAwwjAAIW1c=; b=T4n7B/HDfO8GLn9RDv5a9Mnd7w6QzC1CmmDAy2dGrwaoMO/jJ9ye68xPKJXV0LUP0g HMI9KaeCJNVypsn0VcgiXF0nahQXoHOgDKN4FwRWRycbYlkqaH9q1rmG+kRJ8FGQJ1TS KQOwwrHclrlRKXj4BjzWTg9Tds6QLnXBGQlVYn2K5UHD2lSJLkgLXYfczlptpwyjMoni lRVSC4FnURwvgkpAlTUnIrGGVyJXCmGFRKRzLAt1vP7qj8FHDEynp0phez5v1FcB62jo bg9FLizdXkt4a8l65wUYQQXLTkD0GdTnUAlZekz6904IYqEVSUDgLLvEPRXk+a/P6Ta/ bNSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GmzDwYCwB3ACF6L8pkrzfaM1KU2/zTHOCAwwjAAIW1c=; b=ZTGsD0PgFoKoR9dzO/BtNpTAiMyF937tMbnwRq5WOP0EwqyoueuZKgG4WrPfysqFbG D0iDvfoFqA6h5yi/VHNnADlYQcE+mTYrf5DGSxK+sY1wnCLBvmrPkC37ZeZOv2UVY0JO jfX1lZ91X7kC/1J6/lJvCPSYcfgoRkYHtCw6CjbrNtfS7k1nqlXp2fm/bRrv82i4n6HY /C9FAx9jKELXnSz5JdzHAM7oZvnCIMM4tBYSq7wh2hXaZjCe7HuZZgBDHF9n4Agdkqfu RMF0pGVXVaV5Qw17Pz84Ou9Fk7ijJDQ6+hQydj/S08vwXB0ultzYxFosIgo3nAKpbQNm 1e3A== X-Gm-Message-State: AOAM531xSkIHqElIV0VYkOFgJIAG9gy0VVnXxTGS+tGXXFRrTIOihKMQ 2Ih1RHOzPljSnImysz+W4eu7FA== X-Google-Smtp-Source: ABdhPJytkpleb2goc1M1MLDTsD+ny4hCYPN6kmBxFpTwEmpJaqq+R5jrD51y1ejkMwjS5CKoxfmVRw== X-Received: by 2002:a05:600c:ce:: with SMTP id u14mr7866356wmm.10.1612450375861; Thu, 04 Feb 2021 06:52:55 -0800 (PST) Received: from google.com (230.69.233.35.bc.googleusercontent.com. [35.233.69.230]) by smtp.gmail.com with ESMTPSA id y63sm6195028wmd.21.2021.02.04.06.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 06:52:55 -0800 (PST) Date: Thu, 4 Feb 2021 14:52:52 +0000 From: Quentin Perret To: Will Deacon Subject: Re: [RFC PATCH v2 12/26] KVM: arm64: Introduce a Hyp buddy page allocator Message-ID: References: <20210108121524.656872-1-qperret@google.com> <20210108121524.656872-13-qperret@google.com> <20210202181307.GA17311@willie-the-truck> <20210204143106.GA20792@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210204143106.GA20792@willie-the-truck> Cc: devicetree@vger.kernel.org, kernel-team@android.com, android-kvm@google.com, Catalin Marinas , Fuad Tabba , linux-kernel@vger.kernel.org, Rob Herring , linux-arm-kernel@lists.infradead.org, Marc Zyngier , Frank Rowand , kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Thursday 04 Feb 2021 at 14:31:08 (+0000), Will Deacon wrote: > On Wed, Feb 03, 2021 at 06:33:30PM +0000, Quentin Perret wrote: > > On Tuesday 02 Feb 2021 at 18:13:08 (+0000), Will Deacon wrote: > > > On Fri, Jan 08, 2021 at 12:15:10PM +0000, Quentin Perret wrote: > > > > + * __find_buddy(pool, page 0, order 0) => page 1 > > > > + * __find_buddy(pool, page 0, order 1) => page 2 > > > > + * __find_buddy(pool, page 1, order 0) => page 0 > > > > + * __find_buddy(pool, page 2, order 0) => page 3 > > > > + */ > > > > +static struct hyp_page *__find_buddy(struct hyp_pool *pool, struct hyp_page *p, > > > > + unsigned int order) > > > > +{ > > > > + phys_addr_t addr = hyp_page_to_phys(p); > > > > + > > > > + addr ^= (PAGE_SIZE << order); > > > > + if (addr < pool->range_start || addr >= pool->range_end) > > > > + return NULL; > > > > > > Are these range checks only needed because the pool isn't required to be > > > an exact power-of-2 pages in size? If so, maybe it would be more > > > straightforward to limit the max order on a per-pool basis depending upon > > > its size? > > > > More importantly, it is because pages outside of the pool are not > > guaranteed to be covered by the hyp_vmemmap, so I really need to make > > sure I don't dereference them. > > Wouldn't having a per-pool max order help with that? The issue is, I have no alignment guarantees for the pools, so I may end up with max_order = 0 ... _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEFFDC433E0 for ; Thu, 4 Feb 2021 14:54:06 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5AC5F64F4D for ; Thu, 4 Feb 2021 14:54:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AC5F64F4D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6RCnefsQJ0Xu2N1AK1CAYyafY5jLaD87nok6MgeXJ4s=; b=FsmFlMnzRVcap7Dzp7FslR6Xm lTr87eu0eW4ydARtfHssH5yyChgRWLWKuLPX05OfC5bJrsQhKvgQb9ca3pEp8wL27ERJHaljfwlMO oDmF71GSTRJdyXggQL2e1YeuimXehDRHOmBaFK70W2S1jmluc9QwYZQLr+Xp8ko1MfLeudII9Bddt on+WUfeY8KzPeb4rE3Qek9g+62jDIMkIRpHWEYGcop5yZRBFzwYI3TMdStd7840aMtjKMe+Et8ujS 4D+0fvqj49QB7/h6nOkH8f5PR0hrCsNy9JuhPiyQauYcvu3heee9/fDNYui0gFaMJTca+yYSAIJIK ss1JsxqKg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7g0C-0005EB-2Q; Thu, 04 Feb 2021 14:53:00 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7g09-0005DV-98 for linux-arm-kernel@lists.infradead.org; Thu, 04 Feb 2021 14:52:58 +0000 Received: by mail-wm1-x333.google.com with SMTP id i9so3240360wmq.1 for ; Thu, 04 Feb 2021 06:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GmzDwYCwB3ACF6L8pkrzfaM1KU2/zTHOCAwwjAAIW1c=; b=T4n7B/HDfO8GLn9RDv5a9Mnd7w6QzC1CmmDAy2dGrwaoMO/jJ9ye68xPKJXV0LUP0g HMI9KaeCJNVypsn0VcgiXF0nahQXoHOgDKN4FwRWRycbYlkqaH9q1rmG+kRJ8FGQJ1TS KQOwwrHclrlRKXj4BjzWTg9Tds6QLnXBGQlVYn2K5UHD2lSJLkgLXYfczlptpwyjMoni lRVSC4FnURwvgkpAlTUnIrGGVyJXCmGFRKRzLAt1vP7qj8FHDEynp0phez5v1FcB62jo bg9FLizdXkt4a8l65wUYQQXLTkD0GdTnUAlZekz6904IYqEVSUDgLLvEPRXk+a/P6Ta/ bNSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GmzDwYCwB3ACF6L8pkrzfaM1KU2/zTHOCAwwjAAIW1c=; b=kUCMvywA2r3XSWLm0eks+G1wRozVuxppyi97biGCDqRx1dGLGTBM2TPKa5KrdpNX8U AXxgGDhQ+3jEdpT7kZaEBjtzQkpuzJe7pK0I08sqL5LVYZsuw33G0l+kS25cdKjEKG7S rgqrcryVbIYBrUpm/fmm5/kbZF2t1L4Kbm0GnaYZoSF8b3Ew5IeDrw/IFZdcZzH9S1BX wzO0nfbO+UHOe1hRtAIAOJDDghRU0SplaDc4kqu/PEvFTMoejmOLfhNYVOGORFOCh0db W6MX3BCl8DwEe1MpREDa6Re+MLf4uG5ujAlvZO3fJ9+8woFjRJfv+9mUS7yR7lEI/iqX kG5g== X-Gm-Message-State: AOAM533mv1IqnFn2mwsQ3TyV1PG1beOln7RQPEFUbKEDvBhDFYfB/Zcg WJ08EU/XHrhD9kIj1TdwhL8sJg== X-Google-Smtp-Source: ABdhPJytkpleb2goc1M1MLDTsD+ny4hCYPN6kmBxFpTwEmpJaqq+R5jrD51y1ejkMwjS5CKoxfmVRw== X-Received: by 2002:a05:600c:ce:: with SMTP id u14mr7866356wmm.10.1612450375861; Thu, 04 Feb 2021 06:52:55 -0800 (PST) Received: from google.com (230.69.233.35.bc.googleusercontent.com. [35.233.69.230]) by smtp.gmail.com with ESMTPSA id y63sm6195028wmd.21.2021.02.04.06.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 06:52:55 -0800 (PST) Date: Thu, 4 Feb 2021 14:52:52 +0000 From: Quentin Perret To: Will Deacon Subject: Re: [RFC PATCH v2 12/26] KVM: arm64: Introduce a Hyp buddy page allocator Message-ID: References: <20210108121524.656872-1-qperret@google.com> <20210108121524.656872-13-qperret@google.com> <20210202181307.GA17311@willie-the-truck> <20210204143106.GA20792@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210204143106.GA20792@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210204_095257_384222_2A12CD38 X-CRM114-Status: GOOD ( 21.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, kernel-team@android.com, Suzuki K Poulose , android-kvm@google.com, Catalin Marinas , Fuad Tabba , linux-kernel@vger.kernel.org, Rob Herring , James Morse , linux-arm-kernel@lists.infradead.org, Marc Zyngier , David Brazdil , Frank Rowand , kvmarm@lists.cs.columbia.edu, Julien Thierry Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thursday 04 Feb 2021 at 14:31:08 (+0000), Will Deacon wrote: > On Wed, Feb 03, 2021 at 06:33:30PM +0000, Quentin Perret wrote: > > On Tuesday 02 Feb 2021 at 18:13:08 (+0000), Will Deacon wrote: > > > On Fri, Jan 08, 2021 at 12:15:10PM +0000, Quentin Perret wrote: > > > > + * __find_buddy(pool, page 0, order 0) => page 1 > > > > + * __find_buddy(pool, page 0, order 1) => page 2 > > > > + * __find_buddy(pool, page 1, order 0) => page 0 > > > > + * __find_buddy(pool, page 2, order 0) => page 3 > > > > + */ > > > > +static struct hyp_page *__find_buddy(struct hyp_pool *pool, struct hyp_page *p, > > > > + unsigned int order) > > > > +{ > > > > + phys_addr_t addr = hyp_page_to_phys(p); > > > > + > > > > + addr ^= (PAGE_SIZE << order); > > > > + if (addr < pool->range_start || addr >= pool->range_end) > > > > + return NULL; > > > > > > Are these range checks only needed because the pool isn't required to be > > > an exact power-of-2 pages in size? If so, maybe it would be more > > > straightforward to limit the max order on a per-pool basis depending upon > > > its size? > > > > More importantly, it is because pages outside of the pool are not > > guaranteed to be covered by the hyp_vmemmap, so I really need to make > > sure I don't dereference them. > > Wouldn't having a per-pool max order help with that? The issue is, I have no alignment guarantees for the pools, so I may end up with max_order = 0 ... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02E0DC433DB for ; Thu, 4 Feb 2021 14:55:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C72B164F77 for ; Thu, 4 Feb 2021 14:55:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236961AbhBDOyv (ORCPT ); Thu, 4 Feb 2021 09:54:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236926AbhBDOxi (ORCPT ); Thu, 4 Feb 2021 09:53:38 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54398C0613D6 for ; Thu, 4 Feb 2021 06:52:57 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id j21so524851wmj.0 for ; Thu, 04 Feb 2021 06:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GmzDwYCwB3ACF6L8pkrzfaM1KU2/zTHOCAwwjAAIW1c=; b=T4n7B/HDfO8GLn9RDv5a9Mnd7w6QzC1CmmDAy2dGrwaoMO/jJ9ye68xPKJXV0LUP0g HMI9KaeCJNVypsn0VcgiXF0nahQXoHOgDKN4FwRWRycbYlkqaH9q1rmG+kRJ8FGQJ1TS KQOwwrHclrlRKXj4BjzWTg9Tds6QLnXBGQlVYn2K5UHD2lSJLkgLXYfczlptpwyjMoni lRVSC4FnURwvgkpAlTUnIrGGVyJXCmGFRKRzLAt1vP7qj8FHDEynp0phez5v1FcB62jo bg9FLizdXkt4a8l65wUYQQXLTkD0GdTnUAlZekz6904IYqEVSUDgLLvEPRXk+a/P6Ta/ bNSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GmzDwYCwB3ACF6L8pkrzfaM1KU2/zTHOCAwwjAAIW1c=; b=F+gWfLmN9wIpBsDDXRm316xKWF3Odqlx+S64bOMgkqOqrRC6/6FitpIvyWfbNiCeS2 /BW+UAblw8Oxso2tWs7jrkyOshYSEyLjrtY9W2/tnxksLsIl6b/Ao2XWS7A5+qjuxlMR p/T52HTxZr+ZcoSpfIL8XGWwETxDb4rt5DiwJ2HrNE8Yc1msvC7diedAagm6fe4jNyTb KEeonK+O0Wmy3rGwdA80cayPttMe1Mk2sDzs9Ml83fTHYcv8OBhKvTd31u2nQkB29pG3 iws39AhUNOR8n+aB12fFxMhwrIayFC0sgue88i/asWtuOtPOB9AD9ETOIa8hdlfnPI00 NmuA== X-Gm-Message-State: AOAM533ujLbA3it05q5lrKf1vFhxht4+QoqRmV+nojR2nEO2O2AeKan8 15c7srpmQlxuCOUbNENT8SVSlg== X-Google-Smtp-Source: ABdhPJytkpleb2goc1M1MLDTsD+ny4hCYPN6kmBxFpTwEmpJaqq+R5jrD51y1ejkMwjS5CKoxfmVRw== X-Received: by 2002:a05:600c:ce:: with SMTP id u14mr7866356wmm.10.1612450375861; Thu, 04 Feb 2021 06:52:55 -0800 (PST) Received: from google.com (230.69.233.35.bc.googleusercontent.com. [35.233.69.230]) by smtp.gmail.com with ESMTPSA id y63sm6195028wmd.21.2021.02.04.06.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 06:52:55 -0800 (PST) Date: Thu, 4 Feb 2021 14:52:52 +0000 From: Quentin Perret To: Will Deacon Cc: Catalin Marinas , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, android-kvm@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Fuad Tabba , Mark Rutland , David Brazdil Subject: Re: [RFC PATCH v2 12/26] KVM: arm64: Introduce a Hyp buddy page allocator Message-ID: References: <20210108121524.656872-1-qperret@google.com> <20210108121524.656872-13-qperret@google.com> <20210202181307.GA17311@willie-the-truck> <20210204143106.GA20792@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210204143106.GA20792@willie-the-truck> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Thursday 04 Feb 2021 at 14:31:08 (+0000), Will Deacon wrote: > On Wed, Feb 03, 2021 at 06:33:30PM +0000, Quentin Perret wrote: > > On Tuesday 02 Feb 2021 at 18:13:08 (+0000), Will Deacon wrote: > > > On Fri, Jan 08, 2021 at 12:15:10PM +0000, Quentin Perret wrote: > > > > + * __find_buddy(pool, page 0, order 0) => page 1 > > > > + * __find_buddy(pool, page 0, order 1) => page 2 > > > > + * __find_buddy(pool, page 1, order 0) => page 0 > > > > + * __find_buddy(pool, page 2, order 0) => page 3 > > > > + */ > > > > +static struct hyp_page *__find_buddy(struct hyp_pool *pool, struct hyp_page *p, > > > > + unsigned int order) > > > > +{ > > > > + phys_addr_t addr = hyp_page_to_phys(p); > > > > + > > > > + addr ^= (PAGE_SIZE << order); > > > > + if (addr < pool->range_start || addr >= pool->range_end) > > > > + return NULL; > > > > > > Are these range checks only needed because the pool isn't required to be > > > an exact power-of-2 pages in size? If so, maybe it would be more > > > straightforward to limit the max order on a per-pool basis depending upon > > > its size? > > > > More importantly, it is because pages outside of the pool are not > > guaranteed to be covered by the hyp_vmemmap, so I really need to make > > sure I don't dereference them. > > Wouldn't having a per-pool max order help with that? The issue is, I have no alignment guarantees for the pools, so I may end up with max_order = 0 ...