From patchwork Tue Jun 28 03:04:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bibo mao X-Patchwork-Id: 12897574 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48CABC43334 for ; Tue, 28 Jun 2022 03:05:00 +0000 (UTC) Received: from localhost ([::1]:45032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o61X9-0002bb-D6 for qemu-devel@archiver.kernel.org; Mon, 27 Jun 2022 23:04:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o61WM-0001vp-JX for qemu-devel@nongnu.org; Mon, 27 Jun 2022 23:04:10 -0400 Received: from mail.loongson.cn ([114.242.206.163]:40676 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o61WJ-0000vG-WE for qemu-devel@nongnu.org; Mon, 27 Jun 2022 23:04:10 -0400 Received: from localhost.localdomain (unknown [10.2.9.158]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxb9ugb7piTrBgAA--.7212S2; Tue, 28 Jun 2022 11:04:00 +0800 (CST) From: Mao Bibo To: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Richard Henderson Cc: qemu-devel@nongnu.org Subject: [PATCH] include: set vm hva aligned with huge pagesize on loongarch Date: Tue, 28 Jun 2022 11:04:00 +0800 Message-Id: <20220628030400.1291793-1-maobibo@loongson.cn> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CM-TRAN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Uq_b1DUUUU X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ Received-SPF: pass client-ip=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On loongarch system, page size is 16K rather than 4K like general platforms, and huge pagesize is 32M. This patch sets hva for vm aligned with huge pagesize on loongarch host system. Signed-off-by: Mao Bibo --- include/qemu/osdep.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index b1c161c035..4f9aa53e35 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -451,6 +451,9 @@ extern int madvise(char *, size_t, int); # define QEMU_VMALLOC_ALIGN (256 * 4096) #elif defined(__linux__) && defined(__sparc__) # define QEMU_VMALLOC_ALIGN MAX(qemu_real_host_page_size(), SHMLBA) +#elif defined(__linux__) && defined(__loongarch__) +# define QEMU_VMALLOC_ALIGN (qemu_real_host_page_size() * \ + qemu_real_host_page_size() / sizeof(long)) #else # define QEMU_VMALLOC_ALIGN qemu_real_host_page_size() #endif