Message ID | 20210319100146.1149909-28-qperret@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=5UrE=IR=lists.infradead.org=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@kernel.org> 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 744EEC433E0 for <linux-arm-kernel@archiver.kernel.org>; Fri, 19 Mar 2021 10:15:14 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 5CA9D64EEE for <linux-arm-kernel@archiver.kernel.org>; Fri, 19 Mar 2021 10:15:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CA9D64EEE 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:From:Subject:References:Mime-Version: Message-Id:In-Reply-To:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c7+xng2d03DiKtfu6wnGaFMo2u+bnNjRaHB8ILPybq0=; b=OKWB9j0cBZwFIs yuJ6+CBWSNOjpcHBVp6DgrjGcPfg3u5XVufNvjcgTM/gCD7hL1B0Zeao1/ZQX0Hw7q0yGzFVSp6mP c6ofcX+yB8DFHoZy2RF0NT2fB94zHBHLDbVx2Py2Kb8eDFOvlpo6yOLzsxd8MNGpU6nWQ++KLfVuE tRpznQZBrLbDzsg9ndRibcgcUMuLYHKlknKyaJER7r52M9A49DJY4VyMEm+xRo1PJ+9f+v//dI58E 2RFOwKX2WP/5E92eZp+X1n+3XafsA0RbgUznVin+8wlyT2ZtePBMyo/4nHzuSl1G5lOsIV45V/mi9 FP8Pdc1xOEW+NMDDCSRQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNC7w-0074Rs-6T; Fri, 19 Mar 2021 10:13:08 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNBxx-0070R8-5G for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 10:02:53 +0000 Received: by mail-wr1-x449.google.com with SMTP id m23so16541105wrh.7 for <linux-arm-kernel@lists.infradead.org>; Fri, 19 Mar 2021 03:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=mHH8Es+4fAlRYM4Ijk/d6yzRk425uhOb6R/MTFLjwSk=; b=vr1Infv0oafAKH5dGXpB2sE2KyY8fi5gKOdK/ZDQg7n6l7HYp1znPMsJ1FmWo/94JK Q5NROR6jLJt3VR5aSfrkA1bQgIaRMhSdmz+NnIsMQwE2dBMh+UmTvRoPHnfiQhfcFwfO z9G0L1zluGyUR3P2Y9Us278BSXQV9tvHCSMCUC7U9+Dz8+NCRrqR7VDXPTIy2SikDRtA MShb5pSNk0hjVysWrq0h3cQfJ3IkNYccRfdAT0wp2B/IxAsv0xmB3VFa01XInBM+pLas yrCIq+xqSV7/tjVFcM7LpFeCigsmwChqVLgHmV6PzL80NVLVOsm0q6iR9o2iafDyHt49 XRdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=mHH8Es+4fAlRYM4Ijk/d6yzRk425uhOb6R/MTFLjwSk=; b=ijUd6Rgy6hRWpiEUBx5QVLar2wsM7G68paTkrvlQiCLhfvqjDIZnXUzNBvHHLuYGV1 0K9Z1jDS1QvpNKAQLNNu1Bp1nCMuSg+wrSZZTWUXlgkENeB7cNFsey7Xy2LcDRIMxObI hYTqK3fvf0hOgzJHo4Z1uiEPrKGvuMvkORTsD0v/aJamymHc9jWxlc47mBh5wUdi08jU uQ08+7aTXQte6VnDUprLCXW7+a25p+y6I6v9CKacQGd86nbfrgi5XmLCn9ALngluCSci cClc3N4BZ2AlCL+ihUOXIrZ2MdS0tjm9t2Lp3XUC3z2UWeFewqUEwc3lafcYxWB0LtZn l1MQ== X-Gm-Message-State: AOAM5305R2zy1AD582kVXqrSoLrzgLYiUaBvySAqEgSTpWN7Td6qpyj/ UJ1ZHiNa0X8WLQ127SKWn9BZbdHYOMpC X-Google-Smtp-Source: ABdhPJzSR52Pj+HsbOVVMC9NAbeAqKThSCb8Keh7yqOgsfK429inen/RmXXGyNghUdwdJ/4G7ZtObPiBgE+k X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a1c:b70b:: with SMTP id h11mr2955172wmf.10.1616148167410; Fri, 19 Mar 2021 03:02:47 -0700 (PDT) Date: Fri, 19 Mar 2021 10:01:35 +0000 In-Reply-To: <20210319100146.1149909-1-qperret@google.com> Message-Id: <20210319100146.1149909-28-qperret@google.com> Mime-Version: 1.0 References: <20210319100146.1149909-1-qperret@google.com> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v6 27/38] KVM: arm64: Sort the hypervisor memblocks From: Quentin Perret <qperret@google.com> To: catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com Cc: android-kvm@google.com, seanjc@google.com, mate.toth-pal@arm.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, tabba@google.com, ardb@kernel.org, mark.rutland@arm.com, dbrazdil@google.com, qperret@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_100249_793083_D7DA43CF X-CRM114-Status: GOOD ( 11.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
KVM: arm64: Stage-2 for the host
|
expand
|
diff --git a/arch/arm64/kvm/hyp/reserved_mem.c b/arch/arm64/kvm/hyp/reserved_mem.c index fd42705a3c26..83ca23ac259b 100644 --- a/arch/arm64/kvm/hyp/reserved_mem.c +++ b/arch/arm64/kvm/hyp/reserved_mem.c @@ -6,6 +6,7 @@ #include <linux/kvm_host.h> #include <linux/memblock.h> +#include <linux/sort.h> #include <asm/kvm_host.h> @@ -18,6 +19,23 @@ static unsigned int *hyp_memblock_nr_ptr = &kvm_nvhe_sym(hyp_memblock_nr); phys_addr_t hyp_mem_base; phys_addr_t hyp_mem_size; +static int cmp_hyp_memblock(const void *p1, const void *p2) +{ + const struct memblock_region *r1 = p1; + const struct memblock_region *r2 = p2; + + return r1->base < r2->base ? -1 : (r1->base > r2->base); +} + +static void __init sort_memblock_regions(void) +{ + sort(hyp_memory, + *hyp_memblock_nr_ptr, + sizeof(struct memblock_region), + cmp_hyp_memblock, + NULL); +} + static int __init register_memblock_regions(void) { struct memblock_region *reg; @@ -29,6 +47,7 @@ static int __init register_memblock_regions(void) hyp_memory[*hyp_memblock_nr_ptr] = *reg; (*hyp_memblock_nr_ptr)++; } + sort_memblock_regions(); return 0; }