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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6EA2CC001B0 for ; Mon, 14 Aug 2023 07:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3SrJuQlvXDuHnbKhMM2F339fw5wRum88p34ogsEtaYc=; b=DX6mhMdipebcnF 7/GrZOEgLt3F+YFk31WyGVhLQsuKnxmRZgM4JbmosXVmUhqTwjOwAAgegnk/e3SlpL90RuN8RUkj3 0CoNnVd+HYWdCv3tE8MqWuoJ71IcRcKfgrwvG7ERYZoTUAtTy1507bFUr9RDvJmPcp9BcOkrLQsdg 3xeufqGuW5X4kCMNk5CZHs8Uiqg+BKq4uW8XuVXrk0ENpeqyQeNnGPdAtRcoyC4DibozEslNmhPiK Q1WlNZIRWBcyrFssixXM1Fhl2N4/RXyA8LNc4aZUY7bzyY+Kf40n/uKgrKMdLYutdPIpC1LWJXxBT 4YGrn1W7IfO3WKJjyn6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVSBU-00GOLo-2J; Mon, 14 Aug 2023 07:40:16 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qVSBR-00GOK9-0m for linux-arm-kernel@lists.infradead.org; Mon, 14 Aug 2023 07:40:14 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fe12baec61so36330415e9.2 for ; Mon, 14 Aug 2023 00:40:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691998807; x=1692603607; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2afZnyDCrINJ3gbOl+hmDHdduGv2gb+pC3/Cl898EMU=; b=rNv4SZ9DD4JJgoPgEPxYSgWW0nEP0T+Fp9HhbNAxAbGYa0YQsE1nGYv76l/rQtb8Mo d1dKqM0OVPAXtbidCKSmRLtA6ZUliYFNGKAS0KYMrM8Blr+ZHlNwdQTb0hkHBQARRWmm 6+rr9YBdH0fNvEox5Sp7kvCJGXBinOh4DI85gH0tDRTBREZaTxodtJG9Y+qzeCPUKlwx yvsgLF0NjdKq+Rxa6a3xBvdu0815oZU6Dmv+18JlAxbtkHee0+iv3I9yU4mOlfVRaqVZ iwMZK1KEfBJmpBG24pCc+PRdolZLex+G6bLftXfhtv9q/n4z/qKh64Iu3BTJ8tgEWVUQ 07kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691998807; x=1692603607; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2afZnyDCrINJ3gbOl+hmDHdduGv2gb+pC3/Cl898EMU=; b=WoFTblopz9je7G3cTNIQe6DsPN/1ku7uRZhnFBsFsJgf+pyaYApRBxnsLK/51jwxco ElUADxSlUAYIKETfdp3jgzx51VX2PnsExu6HSc3OCXifBkYW2LvUNhBvjRBT9d6D52AB sus7kpIpUeXIodJvjP24GeKJqho+DnYqg3FJJCPxKXdhtLJHKTYxhDz3s0THhRoo/5dP Tg9AYCpTbsPOAsKtibKC5a60xse8lmS2dCbjz1IQjIxItOvGu16Fb7ir+VFmbtlM0XuG JkwA+StIbpk9pTKXyEUM0/kisQAWMd4V97rdS//GEpjfA+t1BenY1m7k9xq1Vtd+w+EZ YhHA== X-Gm-Message-State: AOJu0YzOkgCyVolTWAyC+IAA5DsvOd4le+C8k3MBvg0Sqcse0HBAgm5r 3Hau/OprlaXEC1IEJZg52+Peng== X-Google-Smtp-Source: AGHT+IHPQn7b/waEqxumGoPwt2Usyo7XuvXA7SasCbtEmIiyAPbtjYjI9Xn0ZwtQswpr36KMUaNDLg== X-Received: by 2002:a05:6000:106:b0:319:6e58:7095 with SMTP id o6-20020a056000010600b003196e587095mr3635276wrx.66.1691998807372; Mon, 14 Aug 2023 00:40:07 -0700 (PDT) Received: from google.com (65.0.187.35.bc.googleusercontent.com. [35.187.0.65]) by smtp.gmail.com with ESMTPSA id q11-20020adff94b000000b00317c742ca9asm13350110wrr.43.2023.08.14.00.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 00:40:06 -0700 (PDT) Date: Mon, 14 Aug 2023 08:40:01 +0100 From: Vincent Donnefort To: Kalesh Singh Cc: maz@kernel.org, oliver.upton@linux.dev, kvmarm@lists.linux.dev, qperret@google.com, smostafa@google.com, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, will@kernel.org Subject: Re: [PATCH v2] KVM: arm64: Remove size-order align in the nVHE hyp private VA range Message-ID: References: <20230811112037.1147863-1-vdonnefort@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230814_004013_295039_22407348 X-CRM114-Status: GOOD ( 20.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org [...] > > +int create_hyp_stack(phys_addr_t phys_addr, unsigned long *haddr) > > +{ > > + unsigned long base; > > + size_t size; > > + int ret; > > + > > + mutex_lock(&kvm_hyp_pgd_mutex); > > + /* > > + * Efficient stack verification using the PAGE_SHIFT bit implies > > + * an alignment of our allocation on the order of the size. > > + */ > > + size = PAGE_SIZE * 2; > > + base = ALIGN_DOWN(io_map_base - size, size); > > + > > + ret = __hyp_alloc_private_va_range(base); > > + > > + mutex_unlock(&kvm_hyp_pgd_mutex); > > + > > + if (ret) { > > + kvm_err("Cannot allocate hyp stack guard page\n"); > > + return ret; > > + } > > + > > + /* > > + * Since the stack grows downwards, map the stack to the page > > + * at the higher address and leave the lower guard page > > + * unbacked. > > + * > > + * Any valid stack address now has the PAGE_SHIFT bit as 1 > > + * and addresses corresponding to the guard page have the > > + * PAGE_SHIFT bit as 0 - this is used for overflow detection. > > + */ > > + ret = __create_hyp_mappings(base + PAGE_SIZE, PAGE_SIZE, phys_addr, > > + PAGE_HYP); > > + if (ret) > > + kvm_err("Cannot map hyp stack\n"); > > Should we reset the io_map_base if the mapping failed here as well? I didn't do it on purpose. Here, I'm releasing the lock and I didn't want to add a non locked __create_hyp_mappings() just for that reset that is probably not binging much. > > Otherwise lgtm, Reviewed-by: Kalesh Singh Thanks for the review! > > Thanks, > Kalesh > > > + > > + *haddr = base + size; > > + > > + return ret; > > +} > > + > > /** > > * create_hyp_io_mappings - Map IO into both kernel and HYP > > * @phys_addr: The physical start address which gets mapped > > > > base-commit: 52a93d39b17dc7eb98b6aa3edb93943248e03b2f > > -- > > 2.41.0.640.ga95def55d0-goog > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel