Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2978440rdh; Wed, 27 Sep 2023 21:05:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFy1bVSThRd54W4m7+DvOKwBOS1dI0tVxD72UAeoy2mSwx/T4oEKtUytx9PCnRzIY7Q5vFF X-Received: by 2002:a05:6102:302b:b0:452:6bb2:3620 with SMTP id v11-20020a056102302b00b004526bb23620mr57221vsa.22.1695873932149; Wed, 27 Sep 2023 21:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695873932; cv=none; d=google.com; s=arc-20160816; b=Qrs4VUx1ShyBMiW7AZf+z6Y/QmYKF+CyXFmpyCW07u7c25moJkeaTQwrtgaEOk5bFQ TPB2fUtNP5ChKOV9WDH9JEU686xE7gbHPASZIKhCdufzC+SI19YHEGMYZbuEl5CPiCvp E1CfyhjS4fD5AqFgiTXIOWLNv1riT6mGGHeo8rGXTpXJUiSg/aYIBazFEkXt47QRGY4J wsHKIDfk5KcyiffjG4flQ3sxSEZ4Y8PEnTBRqAysvCkYpoPBY8E3eupgJtLKvshs9UP4 kkZdppnpd/2+L7ZmjzqYRBqadhiB5bBdejNXDgGggfS2CS7Hj1zi+s2MFWdn9hlXjV4I gJQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=jc70hJdrw6F4cn1nTW8LQSywOX+0kXUur0/EpiMXslA=; fh=0/ExNHxdEV0fLmSPuojjKTsHFOGKXn6GlK7HVSyZh/Y=; b=klrHYsDzQgYCFvJ8WJ9GEM6X/q53GsETRfD2bNXyOSTWbdUPWlFhTCo25pRJsSQ9uV TB6UHsODyeyV6LzLlZlLaQvNJXTiVRYtY/aayVG9aKY+SpbFeX9D+qW/HF6DSRx+xX+E H4P997OiZ8NcOb2irN3Mw56yDINbOpX95Cjlw9goA4QTpj+/HbvgZJh2PsTqlD1DXmSK Flwa7pli7iQzCZ/ehGf8sY2CKU5F4UicIJLH4EFUkx4vIDQDfLBaTIKmAqT+QowUOVUA HPIUxVL9CTXJApbb2O/mtus7Qqc6AIUo1rRBoMWqpsQraqgIziDB6FFsneNvFoqFX1tP LgRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y127-20020a636485000000b00578d6a88716si17821154pgb.3.2023.09.27.21.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 21:05:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 300DD8039574; Wed, 27 Sep 2023 21:04:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230108AbjI1EEf (ORCPT + 99 others); Thu, 28 Sep 2023 00:04:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjI1EEd (ORCPT ); Thu, 28 Sep 2023 00:04:33 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 568E110A; Wed, 27 Sep 2023 21:04:30 -0700 (PDT) Received: from loongson.cn (unknown [10.40.46.158]) by gateway (Coremail) with SMTP id _____8Cx77tM+xRljawtAA--.28291S3; Thu, 28 Sep 2023 12:04:28 +0800 (CST) Received: from [192.168.124.126] (unknown [10.40.46.158]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dxvi9K+xRlXwEVAA--.43483S3; Thu, 28 Sep 2023 12:04:28 +0800 (CST) Subject: Re: [PATCH v2 3/4] KVM: selftests: Add ucall test support for LoongArch To: Sean Christopherson Cc: Shuah Khan , Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Vishal Annapurve , Huacai Chen , WANG Xuerui , loongarch@lists.linux.dev, Peter Xu , Vipin Sharma , maobibo@loongson.cn References: <20230807065137.3408970-1-zhaotianrui@loongson.cn> <20230807065137.3408970-4-zhaotianrui@loongson.cn> From: zhaotianrui Message-ID: <8ac800d7-144d-22f4-fe2c-206aecc9a5dd@loongson.cn> Date: Thu, 28 Sep 2023 12:04:25 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID: AQAAf8Dxvi9K+xRlXwEVAA--.43483S3 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxurW7Kw4Uur43uF1ktF4UZFc_yoW5Jw4kpa 4kC3W5Kr4rKry7AasxXw1vq3WSyrZ7KF4rZr1ayryF9wsFyr1fAr1fKF1jkFy5ua4vgr1k ZFn2gwnIkF1qk3cCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUPIb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU XVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI4 8JMxk0xIA0c2IEe2xFo4CEbIxvr21lc7CjxVAaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64vI r41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_Jrv_JF1lx2IqxVAqx4xG67 AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIY rxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14 v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8 JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07jOa93UUU UU= X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 27 Sep 2023 21:04:46 -0700 (PDT) ?? 2023/9/28 ????4:54, Sean Christopherson ะด??: > On Mon, Aug 07, 2023, Tianrui Zhao wrote: >> Add ucall test support for LoongArch. A ucall is a "hypercall to >> userspace". > Nit, can you explain why LoongArch uses MMIO to trigger ucall, and what alternatives > were considred (if any)? The main reason for the ask is because we've tossed > around the idea of converting all architectures (except s390) to MMIO-based ucall > in order to reduce the number of "flavors" of ucall we have to worry about it. > If MMIO is the only reasonable choice for LoongArch, that's another reason to > double down on MMIO as the primary choice for ucall. Thanks for your reminding about ucall, and our guest can also use hypercall instruction to trigger ucall, so this change will not affect us. Thanks Tianrui Zhao > >> Based-on: <20230803022138.2736430-1-zhaotianrui@loongson.cn> >> Signed-off-by: Tianrui Zhao >> --- >> .../selftests/kvm/lib/loongarch/ucall.c | 43 +++++++++++++++++++ >> 1 file changed, 43 insertions(+) >> create mode 100644 tools/testing/selftests/kvm/lib/loongarch/ucall.c >> >> diff --git a/tools/testing/selftests/kvm/lib/loongarch/ucall.c b/tools/testing/selftests/kvm/lib/loongarch/ucall.c >> new file mode 100644 >> index 000000000000..72868ddec313 >> --- /dev/null >> +++ b/tools/testing/selftests/kvm/lib/loongarch/ucall.c >> @@ -0,0 +1,43 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * ucall support. A ucall is a "hypercall to userspace". >> + * >> + */ >> +#include "kvm_util.h" >> + >> +/* >> + * ucall_exit_mmio_addr holds per-VM values (global data is duplicated by each >> + * VM), it must not be accessed from host code. >> + */ >> +static vm_vaddr_t *ucall_exit_mmio_addr; >> + >> +void ucall_arch_init(struct kvm_vm *vm, vm_paddr_t mmio_gpa) >> +{ >> + vm_vaddr_t mmio_gva = vm_vaddr_unused_gap(vm, vm->page_size, KVM_UTIL_MIN_VADDR); >> + >> + virt_map(vm, mmio_gva, mmio_gpa, 1); >> + >> + vm->ucall_mmio_addr = mmio_gpa; >> + >> + write_guest_global(vm, ucall_exit_mmio_addr, (vm_vaddr_t *)mmio_gva); >> +} >> + >> +void ucall_arch_do_ucall(vm_vaddr_t uc) >> +{ >> + WRITE_ONCE(*ucall_exit_mmio_addr, uc); > Another uber nit, you might want to put this in the header as a static inline to > avoid function calls. I doubt it'll actually matter, but we've had enough weird, > hard-to-debug issues with ucall that minimizing the amount of generated code might > save some future pain.