Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2961622rdh; Wed, 27 Sep 2023 20:09:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEr9bfS6HHSAHzBEpM+/5KsJdbYs0PhSK8RDgGRixKB2/Y7JNAwWFJSbhXwURiQn6wNIoIV X-Received: by 2002:a05:6358:6f92:b0:143:8e40:917b with SMTP id s18-20020a0563586f9200b001438e40917bmr2756rwn.9.1695870571996; Wed, 27 Sep 2023 20:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695870571; cv=none; d=google.com; s=arc-20160816; b=ZcOFnaqZg9WUgRAYtpll8dS6d/bHpPr11eAnR9xqVP5FgLQb1ef0a/aYy+WsHmcET2 uLVAKwrpvu0yHCLJ4bWybKssXKAu/IMrexPY+2vbPeEHhhFyQc8w7Jwefe8KwnvQ+G8s 4Ww3xdGcse1aINOMA2a/Wp/SFqLdwB0GczQ8ULHoW/MWXgF5JQS3/oNIrB5HyfGxpcCJ rsoeqiT30PiMmSiRGqpvlAAiMcA6bb2++IqOt3zizLx57OrAIGv2wRK3/nXfJBtx2gdg urzhfZaOI7iIgEqm0cx4Xxs80ss31cbFD1TH1KknCXHpzLLecmDH03idImrZIzTPpYr0 Mj4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=ojApjJdra5G2e9VG7iCI1/QYu+pQelbcKUfyRfxvagM=; fh=OWpq87H83fhGOGGlS+rpTrb+xlkLEu152lkq6tyxr3Q=; b=vfPgHdkbzMSFTYkyAOOUSgOLSgHKbziPMQEwPjC5njaSl/qWAs2VLNj6cck526NaeX xnlabZ02+Jky3DOhrmrM931pnJexef7PT2jW7O36PmstkeoLZ9pDer3xkf5RgDk4Sc6b ZoJPBkq4Lal3H0/Bfv9Yu1oU7fjVBHeaiM1nUW5gBqlyWye9Gz9yo5d4uFKjPxUxil10 oI/spb+3yeJ9BOkic2SH+OFlke9TblguzTmQU+O1mF3JseZJsXXaoYv6e2QKF7fRqLxj 8wL8iBgKwlgIp+BLUbIPtcu7KKCAxkKzOCELvx3vUXmbudQeF95CHlaW3fhD9RV2J0Qc WxyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=t8EqehXM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id e4-20020a635444000000b005774a3b3efdsi17235265pgm.301.2023.09.27.20.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 20:09:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=t8EqehXM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B25F6807C85E; Wed, 27 Sep 2023 13:55:29 -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 S230101AbjI0UzL (ORCPT + 99 others); Wed, 27 Sep 2023 16:55:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbjI0Uy7 (ORCPT ); Wed, 27 Sep 2023 16:54:59 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAE79CC0 for ; Wed, 27 Sep 2023 13:54:48 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1c6181dacf6so106388025ad.1 for ; Wed, 27 Sep 2023 13:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695848088; x=1696452888; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ojApjJdra5G2e9VG7iCI1/QYu+pQelbcKUfyRfxvagM=; b=t8EqehXMh8Bxqh+7BVXB2x3pkGyMz0aqujzOxWBpTvLB8auz/8GYBhLUL6lTJD+JYb EPr9R2NgOFnQmAiM1LEkCqVhs0SK0R6drtM+PZMElBCgorZj+MQwU071/Orm60XkU3Cg HJ/nj+6LH13MuUaxgK0jP0KgnMWXQNGd3DNqEJwr2+HCzSTzKUPFprbHsohhTWiZEqRz rPAZQfG4BvET2Fm1L+yeSdkV5ZRYUs2qngcB3w6lawSPRYfu087ng/UKsvyjrx5oge1Y mNg9HtP0UDKjl+ToCaHnYGjbAR2jUm7/bDgjPPO9oWNoTxsANjwR3O1L26zXG/cVRaSR jZuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695848088; x=1696452888; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ojApjJdra5G2e9VG7iCI1/QYu+pQelbcKUfyRfxvagM=; b=j1DDBmG28CWLPIFlDLCl6Pm7F9Pq3fF364THHuh2kmxAMTNkxzDwp+zpdUO/Xah4fg IUQM3ikg7DI/GY/YayuTnUEhCyb0JZpsO3Wr3PG+3fmwKnhfuksRetjb3MPkZ4Ft7/su /BFWWLGSmo30LuJGjKCTfYzd37AW6A57qtoKJwNfzwBVsW6Hx1xFQIRiyZXIEBABurPf lUIZRnQeu51eqfWJAnFg9kl+KDM4n5PA7v0KVVt+hCeRnKzuUPGR4PbKQIndyPaMEOxv zkxTpnV+JYWUnl8WCjyjQbbcHfNLUA8QgmNwz9qIeSwjCos46yQnpH0/GY4pYgJH8ofy SvNw== X-Gm-Message-State: AOJu0Yx4EJZR44CQD7CdEVZF/fYBuMGKoZ/tjmTKsGhAXYxhJnFryhZO Nb6UyGmifXReGCOYL+8lj4gHOCTYZjs= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:2452:b0:1bc:4c3d:eb08 with SMTP id l18-20020a170903245200b001bc4c3deb08mr39333pls.8.1695848088093; Wed, 27 Sep 2023 13:54:48 -0700 (PDT) Date: Wed, 27 Sep 2023 13:54:46 -0700 In-Reply-To: <20230807065137.3408970-4-zhaotianrui@loongson.cn> Mime-Version: 1.0 References: <20230807065137.3408970-1-zhaotianrui@loongson.cn> <20230807065137.3408970-4-zhaotianrui@loongson.cn> Message-ID: Subject: Re: [PATCH v2 3/4] KVM: selftests: Add ucall test support for LoongArch From: Sean Christopherson To: Tianrui Zhao 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 Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-8.4 required=5.0 tests=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=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 13:55:29 -0700 (PDT) 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. > 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.