Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18956693rwd; Wed, 28 Jun 2023 03:07:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6fPDoqReom/AUeXZTL+RO/2pWMqY1p1MEPCK4y+t4PgnIzxhY2mwOJ1WVjKbCnfowtVYQh X-Received: by 2002:a05:6830:22f5:b0:6b7:4e25:4c08 with SMTP id t21-20020a05683022f500b006b74e254c08mr7990047otc.12.1687946826721; Wed, 28 Jun 2023 03:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687946826; cv=none; d=google.com; s=arc-20160816; b=Xh/7La0hzMrXGs8skc28RUsrhfNs+xTd0mTmuv7SpR4K3NBg9wcHZlrlGr3asWL/+G jCwsAe0d6YFarYrb0ezGB72U8TvULVgI5z3elvxVNAzq84/u2ygW1kEDJpaL9nefrTYT 3mvYnouhE0J4i5NZE0Bp9NzmFv/z174tEw6VZtf2dMu7yvJ9B2kKSnbi+WYGlRlfbjeA SvpfPVyNP3Nnw6S3SeXXVzclIlE/tJqSPoc+iHiKjxaJAWqU9Aws7uD5QIzuZe4otAla ncyLNcNkBfoMEiYHY3Ao/++Y9nyPZ9jVcJv9p2b604ROrw4zTvktVrtGq0O3CeKob2U8 r+Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Rxz0Z7fQLUkGdiRVWdDmkXmuhlFqTgDrvB6q/b2W8G4=; fh=iZ3uPATqUd8JRcfPseuRFVqqcuEoI7EvjiD1Uetp6O8=; b=f3Dy/2fF5Gc1H3MeTKT6emHF8pjBE6iNFF9Wy6Q54xYpx+TuR5PG8qjb+BWh8VgjAD Pg50NY23obzfK7kE+M02GaNtcygNMlHuf9qLU3B5PSGV8V1iwdEiMU7PzBl3+9XwZ7WH l0oUAqlP2bVJ2+qbXppNVJdUCrYWt4Q6TFlI+K0YmgkW3MZV2urSqsqLcxFDpL5eTOEF fEin3lOY9qUABwb9yc+ywRjC05n9l9i51gxFmmQeglgW5l/vCt3YJLDROlMZucO6lApX lT5xXNGOmh+6s9mawDNEfqjMBk8W/v/LSnjVXdEXw89aL5bbMaKjh/FgbZ9h/fwKr4Sl OyEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=Ag+B3SY2; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a634e04000000b005577eec6c6csi8527148pgb.160.2023.06.28.03.06.53; Wed, 28 Jun 2023 03:07:06 -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=@xen0n.name header.s=mail header.b=Ag+B3SY2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233876AbjF1JzK (ORCPT + 99 others); Wed, 28 Jun 2023 05:55:10 -0400 Received: from mail.xen0n.name ([115.28.160.31]:49980 "EHLO mailbox.box.xen0n.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232646AbjF1Jvc (ORCPT ); Wed, 28 Jun 2023 05:51:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687945890; bh=mERR5o/6GAasOdmhfFEv0s0jaV6yQdbTTBXBhqFAqgI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Ag+B3SY2EAgFH+HU437SHcr9olebrpCEhzkgGhOszvll4+B2qkAon0dWQPULujxqZ HtSHHGOTWf0z5sZCcNI88A/TucYf0UT/cq/COITvzTEPtOsd6cI+elKhe3jo2WQCzh iKK29Zl+6XHUqPRR0+zbcAkiDZ1NCjaPRn/LjwEY= Received: from [100.100.34.13] (unknown [220.248.53.61]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id B59C7600A6; Wed, 28 Jun 2023 17:51:29 +0800 (CST) Message-ID: Date: Wed, 28 Jun 2023 17:51:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v15 27/30] LoongArch: KVM: Implement vcpu world switch Content-Language: en-US To: zhaotianrui , Jinyang He , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Huacai Chen , Greg Kroah-Hartman , loongarch@lists.linux.dev, Jens Axboe , Mark Brown , Alex Deucher , Oliver Upton , maobibo@loongson.cn, Xi Ruoyao , tangyouling@loongson.cn References: <20230626084752.1138621-1-zhaotianrui@loongson.cn> <20230626084752.1138621-28-zhaotianrui@loongson.cn> <7017277c-3721-b417-5215-491efae7c8a9@loongson.cn> From: WANG Xuerui In-Reply-To: <7017277c-3721-b417-5215-491efae7c8a9@loongson.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2023/6/28 16:34, zhaotianrui wrote: > > 在 2023/6/28 上午11:42, Jinyang He 写道: >> On 2023-06-26 16:47, Tianrui Zhao wrote: >> >>> [snip] >> >>> +    ldx.d   t0, t1, t0 >>> +    csrwr    t0, LOONGARCH_CSR_PGDL >>> + >>> +    /* Mix GID and RID */ >>> +    csrrd        t1, LOONGARCH_CSR_GSTAT >>> +    bstrpick.w    t1, t1, CSR_GSTAT_GID_SHIFT_END, CSR_GSTAT_GID_SHIFT >>> +    csrrd        t0, LOONGARCH_CSR_GTLBC >>> +    bstrins.w    t0, t1, CSR_GTLBC_TGID_SHIFT_END, CSR_GTLBC_TGID_SHIFT >>> +    csrwr        t0, LOONGARCH_CSR_GTLBC >>> + >>> +    /* >>> +     * Switch to guest: >>> +     *  GSTAT.PGM = 1, ERRCTL.ISERR = 0, TLBRPRMD.ISTLBR = 0 >>> +     *  ertn >>> +     */ >>> + >>> +    /* >>> +     * Enable intr in root mode with future ertn so that host interrupt >>> +     * can be responsed during VM runs >>> +     * guest crmd comes from separate gcsr_CRMD register >>> +     */ >>> +    ori    t0, zero, CSR_PRMD_PIE >> li.w t0, CSR_PRMD_PIE > Thanks for your advice, and I think it need not to replace it with > "li.w" there, as it has the same meaning with "ori" instruction, and > "ori" instruction is simple and clear enough. The same as the following > "move" instructions. What do you think of it. Just my 2c: I'd agree that pseudo-instructions should be used wherever possible and helping readability. FYI there were similar usages way before, but all were cleaned up with my previous commit 57ce5d3eefac ("LoongArch: Use the "move" pseudo-instruction where applicable"). Such usages apparently came from an era when the LoongArch toolchains didn't support any pseudo-instruction, and are less intuitive especially for someone not familiar with LoongArch assembly. Given that familiarity with LoongArch won't be widespread (unlike with e.g. RISC-V that are adopted more widely), we should optimize for readability when writing code; it's also a best practice in general because code is read way more often than written, and people care about semantics not unnecessary details like "how are moves like this or that materialized". -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/