Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19004098rwd; Wed, 28 Jun 2023 03:51:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5e96KBJMYp61LiZa7750aya7JRGQml7kuSNDhFufinbPCJF37MgombRKqKJWnNLnMa0rlK X-Received: by 2002:a05:6402:404:b0:51b:fbf3:d9a7 with SMTP id q4-20020a056402040400b0051bfbf3d9a7mr9924961edv.39.1687949487079; Wed, 28 Jun 2023 03:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687949487; cv=none; d=google.com; s=arc-20160816; b=ZAQuaUR7BP49Hhnai9qOuPuTpyjpsvb+rwvEkVyU00XN6AJjb0oZi5XYOrrjKNaFeJ UYvWn10aqRPBw20pJvq/x3Vh8CZPI+4HN1UhlZWDja/cmN7Zqrfn30x2xRSZXX7S8xWm HzxjqTC5ebz+nuWHIK7TzBWfI20IRD69ucDPGmPAWvxfzWbZMJ6UZiltCssq7K4QkFRW wz72Dwfsi3lcmE35rhPjmjVPGlihhg/dcyFeDHaKOJbnXLkCiMP5tTLePTchleSI3KLK jl4Hni5i2BDm6l6+WnJUCU1Q5i9zzX03/2/YNVbvWL4sacBgXY5KL+wyGJDdKvgNHfs7 xMgA== 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=XlSlyc0C+NNInKewJYClYGmcJ8RLXBFFC/9hFSsATg4=; fh=DySSCrbkaFRZ4S5Hpc53Os87agmH/LL2TA5XeBHLiGQ=; b=SoNY5ts5SW1AwT2VcJazb/jAwGrHImiCow5XCO8vwGyRWEb9kLGWV/87AYZtxKZIyL bwT+CZuGn8KffxsYS+TA3Xivw8rWr18xSCGJ1+gkYK/UG7Xt0siYIWSNXzeZG0pI4qpB xvTWHBCeBC4XeLMPldxfKM0aitnImTeteUznIb4fwjw/DOWBMa+aZBGnX6rN7T9cRDnH EOMnrnoEVv2JIeOa7NJ/EN77RUonfCKCq4yMhCV8Z/YqKMAlADai9UylnrIfYsnj5Y4s YqQ+a6Fy3IVSNlohCyo9vb1yXGMIrgVN+216/VzMmhQp5kujmVPV1xwyPGoul1hBzFzD Mgiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=SEjp5WBy; 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 ca25-20020aa7cd79000000b0051d9217d06dsi3938395edb.266.2023.06.28.03.51.02; Wed, 28 Jun 2023 03:51:27 -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=SEjp5WBy; 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 S230331AbjF1KZa (ORCPT + 99 others); Wed, 28 Jun 2023 06:25:30 -0400 Received: from mail.xen0n.name ([115.28.160.31]:49050 "EHLO mailbox.box.xen0n.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjF1KWv (ORCPT ); Wed, 28 Jun 2023 06:22:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687947769; bh=HfV60ME+Quish7/YTSK0A/HzQHxZHCQ5Gui95J6/t2I=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=SEjp5WBykVAKJzyXyuKpM9ouuNdeh7g8smkKMrdOvhBEQrhpaKksH9hcpwLVnQ9qg tO+AAsCiehHExUDOXTs4qb2PRFivcB8gBpPDtvRHTXtPLd0mE/3PvP6JBVHxQnyE6v I3Mq+ldAK/PySjR/XWhiWCFtaU2YhXQT7sD96Oek= 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)) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 66C91600A6; Wed, 28 Jun 2023 18:22:48 +0800 (CST) Message-ID: Date: Wed, 28 Jun 2023 18:22:47 +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: bibo mao , 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 , 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> <30261345-45de-8511-e285-fe16ee408ba1@loongson.cn> From: WANG Xuerui In-Reply-To: <30261345-45de-8511-e285-fe16ee408ba1@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 On 2023/6/28 18:11, bibo mao wrote: > > > 在 2023/6/28 17:51, WANG Xuerui 写道: >> 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. > "lu12i.w+srli.w" can be replaced by "li.w t0, KVM_GPGD" > we accept the suggestion two instructions should be replaced with pseudo-instruction. > > For the instruction "ori t0, zero, CSR_PRMD_PIE" > what is advantage of this pseudo-instruction > li.w t0, CSR_PRMD_PIE > > is "ori t0, zero, CSR_PRMD_PIE" hard to understand? It is basic arithmetic instr and easy to understand also. To be frank I do not see the advantage of using li.w, also there is no document that pseudo-instruction should be used with high priority. It depends on the reader. Sure the semantics are the same, but with "ori xx, zero, xx" someone's always going to wonder "why do 'x = 0 | something' when you can simply li.w", because even if it's easy to understand it's still an extra level of indirection. And I've given the historical and general software engineering perspective too; it's not something set in stone, but I'd expect general software development best practices and minimizing any *possible* reader confusion to be acceptable. -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/