Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1025584pxp; Wed, 9 Mar 2022 19:01:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzowicnhB2eDrndfKi03dTGpZWlMMTcG/y3MPzy2/PpxChUsDwSe5RKTupj0I0N6U17Js2o X-Received: by 2002:a17:907:2d23:b0:6da:961c:8c28 with SMTP id gs35-20020a1709072d2300b006da961c8c28mr2444010ejc.18.1646881280326; Wed, 09 Mar 2022 19:01:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646881280; cv=none; d=google.com; s=arc-20160816; b=Qxkm4W98E001Uac9vb/cv9Ibgv4LL3vX550zrn8m4pricCTtpvQwkjxRfsDL8A1H6F 2Izgi/27P2Vg1XpobEzvkAqj4wjtl6FvX0DvadWsWrCbmQqoCig8i1v9oiS1iG1syhzj 1zvjo6gtaAShf0kRS6vhNSjj5kKe8rJbXBQ2DxLJ0VQ8kvoNw8+HTOiB66VQdQk0JpFw 2g3ABTwx2rycVQmTeNXRt7ou4fMHgjiK/YPmn946PX9Y+NlsCt43OPhOZpdsSVHggDjD TfF1knSqQ++RN7B3yRQCtHXA91lYtKZwXT4vCFScitfb6WCEU4MLMfHW6MKtp/0ZiyLo YvIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZgHou8MqoXhRtzbJoo/yhan8iXTUzQE6PBiS2FKYRVk=; b=vtvHwEwn14dsKbFSn8NV46Ka5QzbG8jPbxOK5rTqJAq8HoBs0aCW+UjYuCDglma952 vy+9Ls5DUQ/mRregaEaVspyor6TJa6J6v9XFkuQ8o8dW+znAKoaGqYCCsqaze9MWSosE DAo4p30689q/Ug2w+eP3OYC4pEx8GH+TtAGzIS00GqN0eM/fpS4x9VVEjHQGDY68vu1J r9YQItDLtrzZLGCUrZWmRAK1I/PbIXAgtjFKOuNQ4tXv08yjbm2HEsPWXGE8xpWT71nl o4RoORngkBVaeW0LGXWl3i4i+HeyQmiHIdY46f3WDrrT1+gIibsyrs+fuFvcOjkmY+0g ukng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ApCIZr+M; 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 gn8-20020a1709070d0800b006daa21a4cbesi2696909ejc.118.2022.03.09.19.00.55; Wed, 09 Mar 2022 19:01:20 -0800 (PST) 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=20210112 header.b=ApCIZr+M; 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 S236303AbiCIRFR (ORCPT + 99 others); Wed, 9 Mar 2022 12:05:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235748AbiCIRCl (ORCPT ); Wed, 9 Mar 2022 12:02:41 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99973192C96 for ; Wed, 9 Mar 2022 08:50:50 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id r187-20020a1c2bc4000000b003810e6b192aso1853609wmr.1 for ; Wed, 09 Mar 2022 08:50:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZgHou8MqoXhRtzbJoo/yhan8iXTUzQE6PBiS2FKYRVk=; b=ApCIZr+MN6aee2cgqpPw+PV2CFMmrVy6Tba9Ix98g0JMbS/aPhT2nRYGytV5+Ew1dK z0tHBjwNiHk8ULLoDS6I4IZtOD1vgXLJ6jKahOF+IevRmjrWjq4mt6e2HLiiL22auFD7 MnRfKwypFDEgPWQJnHfOysoynPTsTdtaTl0uYlV7qZCkg7zwXRBiAvgulaFHIPHCW0x5 Hnuu1IVwWai8BPnp6D9ccORnN9fLNaPf57yibDLFRvp1pBm3n06ltkKX9Je5tohqyKmH OCBB1atg/D7hEWIqw31e2vKDb8speQ438g9RZRyONaVt0go3FMRBOFD7EDZjPJEfAe+j YQcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZgHou8MqoXhRtzbJoo/yhan8iXTUzQE6PBiS2FKYRVk=; b=1YVNKkZVL1RiUD/d9Mk5HCkB3CcXUS1oPF+6Fnq2MFg9J9UPGZIrqT83nY6LooY+Yr TE04FZvznh514Kgmz4oCIWH4+tW00K3OIr7Odo/yBEokv5cnyFkAG8uDXHV/3dzmSi++ WscuEshIN221ptPL0AwqUT3xKa9SrMoBw8RXHoDEEfzhHKSeEWtAnlF8wyL7fs479Xpy GyFqTm+TvdjAD2vnGsPVpJ49iApNldMOnO9VYVjf8UOst7XPZ7zjhMUyabLLaXlmFUAY KvsCyVhtNEe11aGOu3UTokMjUq1C6BTtZoLxt1wC81Vi3YYSL7ke+JQBoye7dcOvUOBl cRZQ== X-Gm-Message-State: AOAM5314EcS3mWIKt/VCfjQA7fOUTHJOy8N+bEk18fcwd4wwxbPEilo5 JWlaKG6F96SiHEntGSDa8n6mrw== X-Received: by 2002:a05:600c:3b1c:b0:389:8677:6c73 with SMTP id m28-20020a05600c3b1c00b0038986776c73mr210606wms.192.1646844648795; Wed, 09 Mar 2022 08:50:48 -0800 (PST) Received: from google.com ([2a00:79e0:d:210:24bb:c5c7:5788:287d]) by smtp.gmail.com with ESMTPSA id v20-20020a7bcb54000000b0037fa63db8aasm5972989wmj.5.2022.03.09.08.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 08:50:48 -0800 (PST) Date: Wed, 9 Mar 2022 16:50:45 +0000 From: Quentin Perret To: Kalesh Singh Cc: Stephen Boyd , Will Deacon , Marc Zyngier , Fuad Tabba , Suren Baghdasaryan , "Cc: Android Kernel" , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Mark Rutland , Mark Brown , Masami Hiramatsu , Peter Collingbourne , "Madhavan T. Venkataraman" , Andrew Scull , "moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)" , kvmarm , LKML Subject: Re: [PATCH v5 1/8] KVM: arm64: Introduce hyp_alloc_private_va_range() Message-ID: References: <20220307184935.1704614-1-kaleshsingh@google.com> <20220307184935.1704614-2-kaleshsingh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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 Tuesday 08 Mar 2022 at 15:09:18 (-0800), Kalesh Singh wrote: > On Tue, Mar 8, 2022 at 12:21 PM Stephen Boyd wrote: > > It looks odd to use an error pointer casted to unsigned long to return > > from an address allocation function. Why not pass a pointer for base > > like the function was written before and return an int from this > > function with 0 for success and negative error value?Otherwise some > > sort of define should made like DMA_MAPPING_ERROR and that can be used > > to indicate to the caller that the allocation failed, or a simple zero > > may work? > > I wanted to keep consistent between the pkvm and traditional nvhe > code. I will refactor both *alloc_private_va_range() functions to take > a pointer and return an int error if that's preferred. There would > still be a case of this kind of cast in > __pkvm_create_private_mapping() which does return an unsigned long > address or ERR_PTR(...). It looks like it was made to return the > address to facilitate use as a hypercall (@Quentin CMIW). Yep, passing everything by value was much easier to cross the EL1/EL2 boundary as that avoids having the hypervisor map kernel memory and all that fun. But Stephen's point is fair, so no objection from to keep this little dance confined to the hypercall wrapper and make the function signature nicer and easier to use for the rest of the code. Cheers, Quentin