From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70AA8C43461 for ; Mon, 7 Sep 2020 09:47:09 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id CF0AF20C09 for ; Mon, 7 Sep 2020 09:47:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="19AbdD+E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF0AF20C09 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 33C364B5CE; Mon, 7 Sep 2020 05:47:08 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@kernel.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9P0+R5ZIlnI7; Mon, 7 Sep 2020 05:47:07 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 0E6164B5CF; Mon, 7 Sep 2020 05:47:07 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 725E34B5CD for ; Mon, 7 Sep 2020 05:47:05 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P3fRrM6BpoLd for ; Mon, 7 Sep 2020 05:47:04 -0400 (EDT) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 664204B5C9 for ; Mon, 7 Sep 2020 05:47:04 -0400 (EDT) Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 49EFA2078E; Mon, 7 Sep 2020 09:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599472023; bh=cFHskjvmHO3vzxD+eGBoRNZ+sFpiHGFme6jLOuWP8Uc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=19AbdD+EC1bO4XviCsVbOEsgKBlvuTcIcRwYpDXdAbiyDIC2ngljNeSByIj6g2WwR pwHlJAa2zca7ViqS+HXJHlbRqiyn/WpxFytm5SMsvxtaqOBqDi0a5jaudF1eVdGURu jTZbUs3gK3gLc/gZXJVqSV1JOAEE6FHqZ7nCuP54= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kFDjp-009iuT-BE; Mon, 07 Sep 2020 10:47:01 +0100 MIME-Version: 1.0 Date: Mon, 07 Sep 2020 10:47:01 +0100 From: Marc Zyngier To: Jianyong Wu Subject: Re: [PATCH v14 08/10] ptp: arm64: Enable ptp_kvm for arm64 In-Reply-To: References: <20200904092744.167655-1-jianyong.wu@arm.com> <20200904092744.167655-9-jianyong.wu@arm.com> <874kocmqqx.wl-maz@kernel.org> <366387fa507f9c5d5044549cea958ce1@kernel.org> User-Agent: Roundcube Webmail/1.4.8 Message-ID: <67f3381467d02c8d3f25682cd99898e9@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: Jianyong.Wu@arm.com, netdev@vger.kernel.org, yangbo.lu@nxp.com, john.stultz@linaro.org, tglx@linutronix.de, pbonzini@redhat.com, sean.j.christopherson@intel.com, richardcochran@gmail.com, Mark.Rutland@arm.com, will@kernel.org, Suzuki.Poulose@arm.com, Steven.Price@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Steve.Capper@arm.com, Justin.He@arm.com, nd@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: Justin He , kvm@vger.kernel.org, netdev@vger.kernel.org, richardcochran@gmail.com, linux-kernel@vger.kernel.org, sean.j.christopherson@intel.com, Steven Price , john.stultz@linaro.org, yangbo.lu@nxp.com, pbonzini@redhat.com, tglx@linutronix.de, nd , will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On 2020-09-07 10:28, Jianyong Wu wrote: >> -----Original Message----- >> From: Marc Zyngier >> Sent: Monday, September 7, 2020 4:55 PM >> To: Jianyong Wu [...] >> >> arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_FEATUR >> >> ES_FUNC_ID, >> >> > + &hvc_res); >> >> > + if (!(hvc_res.a0 | BIT(ARM_SMCCC_KVM_FUNC_KVM_PTP))) >> >> > + return -EOPNOTSUPP; >> >> > + >> >> > + return 0; >> >> >> >> What happens if the >> >> ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID function isn't >> implemented >> >> (on an old kernel or a non-KVM hypervisor)? The expected behaviour is >> >> that a0 will contain SMCCC_RET_NOT_SUPPORTED, which is -1. >> >> The result is that this function always returns "supported". Not an >> >> acceptable behaviour. >> >> >> > Oh! it's really a stupid mistake, should be "&" not "|". >> >> But even then. (-1 & whatever) is always true. > > Yeah, what about checking if a0 is non-negative first? Like: > if (hvc_res.a0 < 0 || !(hvc_res.a0 & BIT(ARM_SMCCC_KVM_FUNC_KVM_PTP))) > return -EOPNOTSUPP; I don't get it. You already carry a patch from Will that gives you a way to check for a service (kvm_arm_hyp_service_available()). Why do you need to reinvent the wheel? M. -- Jazz is not dead. It just smells funny... _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E6B4C43461 for ; Mon, 7 Sep 2020 09:48:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C558C2078E for ; Mon, 7 Sep 2020 09:48:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IppqtTEw"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="19AbdD+E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C558C2078E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/8NLxFZ3JLLl4F31yT/LUzy0yX/m+bQHDVRtfZAxa/k=; b=IppqtTEwM5OEg7uSa8xmDr0AH xaF6N0t1fYWGY4IYTFVjv2ec8b7T6Ht6vPOkZa5jF5qdtbFcZWrf93EygRG30EDPD+5Jgf3sQlrnv HicPT2GxIVjeVScg3INSNcmsghG+R4rJdWMOGWvpktkqBKbHaMn4l83rSwO7kJSWS51JcsJJYQ68a PGyeumy7jovHA60snS26kjIGCdzpLDPTXiXLNpRQD/yaevA8Ta8Nh0mM82oqcK9WK6mt1VHCAnguJ nLhfQu+B1WP7CbGrm9JolXbJW21XRfGzhdArZIoNEYIanN+BnGnCBJ12g2+PH+kimgcqFxshrhWvx CZmj0dFhQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFDjt-0005rK-Vu; Mon, 07 Sep 2020 09:47:06 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFDjs-0005qv-5j for linux-arm-kernel@lists.infradead.org; Mon, 07 Sep 2020 09:47:04 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 49EFA2078E; Mon, 7 Sep 2020 09:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599472023; bh=cFHskjvmHO3vzxD+eGBoRNZ+sFpiHGFme6jLOuWP8Uc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=19AbdD+EC1bO4XviCsVbOEsgKBlvuTcIcRwYpDXdAbiyDIC2ngljNeSByIj6g2WwR pwHlJAa2zca7ViqS+HXJHlbRqiyn/WpxFytm5SMsvxtaqOBqDi0a5jaudF1eVdGURu jTZbUs3gK3gLc/gZXJVqSV1JOAEE6FHqZ7nCuP54= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kFDjp-009iuT-BE; Mon, 07 Sep 2020 10:47:01 +0100 MIME-Version: 1.0 Date: Mon, 07 Sep 2020 10:47:01 +0100 From: Marc Zyngier To: Jianyong Wu Subject: Re: [PATCH v14 08/10] ptp: arm64: Enable ptp_kvm for arm64 In-Reply-To: References: <20200904092744.167655-1-jianyong.wu@arm.com> <20200904092744.167655-9-jianyong.wu@arm.com> <874kocmqqx.wl-maz@kernel.org> <366387fa507f9c5d5044549cea958ce1@kernel.org> User-Agent: Roundcube Webmail/1.4.8 Message-ID: <67f3381467d02c8d3f25682cd99898e9@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: Jianyong.Wu@arm.com, netdev@vger.kernel.org, yangbo.lu@nxp.com, john.stultz@linaro.org, tglx@linutronix.de, pbonzini@redhat.com, sean.j.christopherson@intel.com, richardcochran@gmail.com, Mark.Rutland@arm.com, will@kernel.org, Suzuki.Poulose@arm.com, Steven.Price@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Steve.Capper@arm.com, Justin.He@arm.com, nd@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200907_054704_328970_878CA8D3 X-CRM114-Status: GOOD ( 15.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Justin He , kvm@vger.kernel.org, Suzuki Poulose , netdev@vger.kernel.org, richardcochran@gmail.com, Steve Capper , linux-kernel@vger.kernel.org, sean.j.christopherson@intel.com, Steven Price , john.stultz@linaro.org, yangbo.lu@nxp.com, pbonzini@redhat.com, tglx@linutronix.de, nd , will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-09-07 10:28, Jianyong Wu wrote: >> -----Original Message----- >> From: Marc Zyngier >> Sent: Monday, September 7, 2020 4:55 PM >> To: Jianyong Wu [...] >> >> arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_FEATUR >> >> ES_FUNC_ID, >> >> > + &hvc_res); >> >> > + if (!(hvc_res.a0 | BIT(ARM_SMCCC_KVM_FUNC_KVM_PTP))) >> >> > + return -EOPNOTSUPP; >> >> > + >> >> > + return 0; >> >> >> >> What happens if the >> >> ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID function isn't >> implemented >> >> (on an old kernel or a non-KVM hypervisor)? The expected behaviour is >> >> that a0 will contain SMCCC_RET_NOT_SUPPORTED, which is -1. >> >> The result is that this function always returns "supported". Not an >> >> acceptable behaviour. >> >> >> > Oh! it's really a stupid mistake, should be "&" not "|". >> >> But even then. (-1 & whatever) is always true. > > Yeah, what about checking if a0 is non-negative first? Like: > if (hvc_res.a0 < 0 || !(hvc_res.a0 & BIT(ARM_SMCCC_KVM_FUNC_KVM_PTP))) > return -EOPNOTSUPP; I don't get it. You already carry a patch from Will that gives you a way to check for a service (kvm_arm_hyp_service_available()). Why do you need to reinvent the wheel? M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9725C43461 for ; Mon, 7 Sep 2020 09:47:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AE812078E for ; Mon, 7 Sep 2020 09:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599472034; bh=cFHskjvmHO3vzxD+eGBoRNZ+sFpiHGFme6jLOuWP8Uc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=xGtURswLDdumDkhXacmiunLoO7002kdKG1+NPZLHoB9ROnCUYDWrnQ27h7kvcqNEf /FRVOTXerTxqwOpZdOUm4plaxweCYM6PBpeLWfZLveEviJbtzxWb/Ng1RObPAkBS3N hNA3tmvI/Khb7p4/UBMeVAQ29aO6BBzA8/T9rgGc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728369AbgIGJrF (ORCPT ); Mon, 7 Sep 2020 05:47:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:44148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726301AbgIGJrE (ORCPT ); Mon, 7 Sep 2020 05:47:04 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 49EFA2078E; Mon, 7 Sep 2020 09:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599472023; bh=cFHskjvmHO3vzxD+eGBoRNZ+sFpiHGFme6jLOuWP8Uc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=19AbdD+EC1bO4XviCsVbOEsgKBlvuTcIcRwYpDXdAbiyDIC2ngljNeSByIj6g2WwR pwHlJAa2zca7ViqS+HXJHlbRqiyn/WpxFytm5SMsvxtaqOBqDi0a5jaudF1eVdGURu jTZbUs3gK3gLc/gZXJVqSV1JOAEE6FHqZ7nCuP54= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kFDjp-009iuT-BE; Mon, 07 Sep 2020 10:47:01 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 07 Sep 2020 10:47:01 +0100 From: Marc Zyngier To: Jianyong Wu Cc: netdev@vger.kernel.org, yangbo.lu@nxp.com, john.stultz@linaro.org, tglx@linutronix.de, pbonzini@redhat.com, sean.j.christopherson@intel.com, richardcochran@gmail.com, Mark Rutland , will@kernel.org, Suzuki Poulose , Steven Price , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Steve Capper , Justin He , nd Subject: Re: [PATCH v14 08/10] ptp: arm64: Enable ptp_kvm for arm64 In-Reply-To: References: <20200904092744.167655-1-jianyong.wu@arm.com> <20200904092744.167655-9-jianyong.wu@arm.com> <874kocmqqx.wl-maz@kernel.org> <366387fa507f9c5d5044549cea958ce1@kernel.org> User-Agent: Roundcube Webmail/1.4.8 Message-ID: <67f3381467d02c8d3f25682cd99898e9@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: Jianyong.Wu@arm.com, netdev@vger.kernel.org, yangbo.lu@nxp.com, john.stultz@linaro.org, tglx@linutronix.de, pbonzini@redhat.com, sean.j.christopherson@intel.com, richardcochran@gmail.com, Mark.Rutland@arm.com, will@kernel.org, Suzuki.Poulose@arm.com, Steven.Price@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Steve.Capper@arm.com, Justin.He@arm.com, nd@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 2020-09-07 10:28, Jianyong Wu wrote: >> -----Original Message----- >> From: Marc Zyngier >> Sent: Monday, September 7, 2020 4:55 PM >> To: Jianyong Wu [...] >> >> arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_FEATUR >> >> ES_FUNC_ID, >> >> > + &hvc_res); >> >> > + if (!(hvc_res.a0 | BIT(ARM_SMCCC_KVM_FUNC_KVM_PTP))) >> >> > + return -EOPNOTSUPP; >> >> > + >> >> > + return 0; >> >> >> >> What happens if the >> >> ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID function isn't >> implemented >> >> (on an old kernel or a non-KVM hypervisor)? The expected behaviour is >> >> that a0 will contain SMCCC_RET_NOT_SUPPORTED, which is -1. >> >> The result is that this function always returns "supported". Not an >> >> acceptable behaviour. >> >> >> > Oh! it's really a stupid mistake, should be "&" not "|". >> >> But even then. (-1 & whatever) is always true. > > Yeah, what about checking if a0 is non-negative first? Like: > if (hvc_res.a0 < 0 || !(hvc_res.a0 & BIT(ARM_SMCCC_KVM_FUNC_KVM_PTP))) > return -EOPNOTSUPP; I don't get it. You already carry a patch from Will that gives you a way to check for a service (kvm_arm_hyp_service_available()). Why do you need to reinvent the wheel? M. -- Jazz is not dead. It just smells funny...