Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1330407rwo; Wed, 2 Aug 2023 12:12:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlH8TcyqYo4ASy5lqd3bk1+BWfvBfXI0DztOAEx43uvQeXxzATfV8bTesQsxaGyWIruvzpw2 X-Received: by 2002:a17:906:538e:b0:992:7e1f:8419 with SMTP id g14-20020a170906538e00b009927e1f8419mr5382519ejo.2.1691003564014; Wed, 02 Aug 2023 12:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691003563; cv=none; d=google.com; s=arc-20160816; b=zy1iRfvyeqcUQdP9GlIVKi1YbhN+iXxN0UKM04O8wq+qH1dsEmfPDG61bHMQEOzlNx 0AGRpnYNSCIIvNvYlqezErWZ7zzACTXjhdp9tmgSZEWM6+Z6JBcASPbdksWfXAmwMHjF FcjLQzIBhMPV4mF0ce6wSjWlik4o/8rfaF06KCzrGYTrtmbLvep66UsMdi2jJc+h4XBY cc7D4fP9oSHsYG0eqs265E5BPHycdrmLWb815bDHvq6PR9rZ3oQ5RasyVgEROG2CsXMd pbFLVixXVfjCDqi2rveiaIUmVLi2G64Wx5uywtQaUW3rql6mCTqrT+4EJ+wMogSS+QYo K89Q== 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=uoCuB3mffhSds51iMp00O5xm+yzIoOPBsVBHjFLh+kk=; fh=zucpp8MTujBKF102SNBmrZrEcggo7osgWjpgKV7+jnE=; b=foFeT6JnKFxxa5iNkkH6MSsTsK0IOxjBEZ8j2TSnd7L1j13x45wxcsL7lCzOFMwxbk H67lQg3zr6CwFB2feUnSZCZ6kjrKGpPURuSaLsNbP27EkSzY2cK0RRwcnykV8Tmt7VW7 uRGecZCiGmVRK+W6mBPfIn248T2mRSkWwEDTnZpAcx3B/XfoETk75bXmyNylikLFQmzD J5YtvkSOT/gwZL61SLmVXMsJac/8qtxYYBVq73XMsXmFhcsQADd/5cKxFCf+MX5/e1TB 20ZHv05Qphul8H3ajLEtIQbi3kTJAOG+UUHIPcO8N25HNuDdrN68WWcOg88dheJU4utH ceWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=KLHPbrCv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gl23-20020a170906e0d700b0099bd1a1d025si7519096ejb.199.2023.08.02.12.12.17; Wed, 02 Aug 2023 12:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=KLHPbrCv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231656AbjHBRBj (ORCPT + 99 others); Wed, 2 Aug 2023 13:01:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231609AbjHBRBh (ORCPT ); Wed, 2 Aug 2023 13:01:37 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554CC2708 for ; Wed, 2 Aug 2023 10:01:36 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1bbbc4ae328so1106795ad.1 for ; Wed, 02 Aug 2023 10:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690995696; x=1691600496; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=uoCuB3mffhSds51iMp00O5xm+yzIoOPBsVBHjFLh+kk=; b=KLHPbrCvHeyGLM2mw8D5f6rzBwkaj3O8dVqo8w7auH/ZjSB06l2wTkYC5pFLHf/78U 5h8Frwj4ZSV54PbzQvd+uXOKXkwOmgjwEu90JEHUoJUxwWxSqbk0T2DrxN+GkE60zh7B hVQQbPhTOOd7h08BeGFSpCTp41ZpkKcaJOJfWvHgm9lPTMiVCxJAe66XjXBKR1V9KMFW 4r9yr9u6C7TVLn2QStyR38cAdCj+fJaYtTsO1ZEym7WH4ByLunYi25lH1aj4eeWNla8Q nqyiuY6+o/3nPaNg/RiYAe9+5rTbvOU74ZvT0zz4vknk6DL0cOcQyOa57BUKgB0wDf31 2mKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690995696; x=1691600496; 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=uoCuB3mffhSds51iMp00O5xm+yzIoOPBsVBHjFLh+kk=; b=BkHXyk2QeLLkxlZdLBd7vLwH/NsTeSuSQK5CPe18najg3fTTs6xcuL6mm19Dt9pNwb h1OP6Praxx6rURRfukKf7ESbrGBmP9e523YcfFuY9avKjToIJBfjlQ9/3HeuxcuB9tV3 PxLaFY1FZmsroJgpy1beyxzlEruR1IYjyZetjzq/CSxa8lWA1Eut3IwvM5yyY3HNThgD mz/S43Rnn+NTw8/Mh4Ol3PzI0J8YoK3IvayGOoP2XL8ZldreRRH0ar+K092k57ooAMGn Ig0wVmuW1N7R+2kLRk+fcvvDIcpFHBmQ9FR8sb1f3kn1IYJlFGC6esMtFnRvbWKTby6Z jOjw== X-Gm-Message-State: ABy/qLbwYPwFuEgs4i2v//g4W3vGrq5CqwlKBuCpNeM5lOmok+1GvhRk 7Ls+JkBfoqyjLPv9sXvK63psBpGvpGE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:f682:b0:1b1:7336:2637 with SMTP id l2-20020a170902f68200b001b173362637mr92471plg.11.1690995695687; Wed, 02 Aug 2023 10:01:35 -0700 (PDT) Date: Wed, 2 Aug 2023 10:01:34 -0700 In-Reply-To: <20230801020206.1957986-2-zhaotianrui@loongson.cn> Mime-Version: 1.0 References: <20230801020206.1957986-1-zhaotianrui@loongson.cn> <20230801020206.1957986-2-zhaotianrui@loongson.cn> Message-ID: Subject: Re: [PATCH v1 1/4] selftests: kvm: Add kvm selftests header files 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=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 01, 2023, Tianrui Zhao wrote: > Add kvm selftests header files for LoongArch, including processor.h, > sysreg.h, and kvm_util_base.h. Those mainly contain LoongArch CSR > register defines and page table information. > > Based-on: <20230720062813.4126751-1-zhaotianrui@loongson.cn> > Signed-off-by: Tianrui Zhao > --- > .../selftests/kvm/include/kvm_util_base.h | 5 ++ > .../kvm/include/loongarch/processor.h | 28 ++++++ > .../selftests/kvm/include/loongarch/sysreg.h | 89 +++++++++++++++++++ > 3 files changed, 122 insertions(+) > create mode 100644 tools/testing/selftests/kvm/include/loongarch/processor.h > create mode 100644 tools/testing/selftests/kvm/include/loongarch/sysreg.h > > diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h > index 07732a157ccd..8747127e0bab 100644 > --- a/tools/testing/selftests/kvm/include/kvm_util_base.h > +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h > @@ -197,6 +197,11 @@ extern enum vm_guest_mode vm_mode_default; > #define MIN_PAGE_SHIFT 12U > #define ptes_per_page(page_size) ((page_size) / 8) > > +#elif defined(__loongarch__) > +#define VM_MODE_DEFAULT VM_MODE_P36V47_16K > +#define MIN_PAGE_SHIFT 14U > +#define ptes_per_page(page_size) ((page_size) / 8) > + > #endif > > #define MIN_PAGE_SIZE (1U << MIN_PAGE_SHIFT) > diff --git a/tools/testing/selftests/kvm/include/loongarch/processor.h b/tools/testing/selftests/kvm/include/loongarch/processor.h > new file mode 100644 > index 000000000000..d67796af51a0 > --- /dev/null > +++ b/tools/testing/selftests/kvm/include/loongarch/processor.h > @@ -0,0 +1,28 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * LoongArch processor specific defines Nit, my preference is to not bother with these types of comments, it should be quite obvious from the file name that that everything in here is LoongArch specific. > + */ > +#ifndef SELFTEST_KVM_PROCESSOR_H > +#define SELFTEST_KVM_PROCESSOR_H > + > +#include > +#define _PAGE_VALID_SHIFT 0 > +#define _PAGE_DIRTY_SHIFT 1 > +#define _PAGE_PLV_SHIFT 2 /* 2~3, two bits */ > +#define _CACHE_SHIFT 4 /* 4~5, two bits */ > +#define _PAGE_PRESENT_SHIFT 7 > +#define _PAGE_WRITE_SHIFT 8 > + > +#define PLV_KERN 0 > +#define PLV_USER 3 > +#define PLV_MASK 0x3 > + > +#define _PAGE_VALID (0x1UL << _PAGE_VALID_SHIFT) > +#define _PAGE_PRESENT (0x1UL << _PAGE_PRESENT_SHIFT) > +#define _PAGE_WRITE (0x1UL << _PAGE_WRITE_SHIFT) > +#define _PAGE_DIRTY (0x1UL << _PAGE_DIRTY_SHIFT) > +#define _PAGE_USER (PLV_USER << _PAGE_PLV_SHIFT) > +#define __READABLE (_PAGE_VALID) > +#define __WRITEABLE (_PAGE_DIRTY | _PAGE_WRITE) > +#define _CACHE_CC (0x1UL << _CACHE_SHIFT) /* Coherent Cached */ > +#endif > diff --git a/tools/testing/selftests/kvm/include/loongarch/sysreg.h b/tools/testing/selftests/kvm/include/loongarch/sysreg.h > new file mode 100644 > index 000000000000..04f53674c9d8 > --- /dev/null > +++ b/tools/testing/selftests/kvm/include/loongarch/sysreg.h Any reason these can't simply go in processor.h? Neither file is particular large, especially for CPU definition files. > @@ -0,0 +1,89 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +#ifndef SELFTEST_KVM_SYSREG_H > +#define SELFTEST_KVM_SYSREG_H > + > +/* > + * note that this declaration raises a checkpatch warning, but > + * no good way to avoid it. > + */ Definitely drop this comment, once the patch is applied the fact that checkpatch complains is irrelevant. > +#define zero $r0