Received: by 2002:ac2:4c03:0:0:0:0:0 with SMTP id t3csp121596lfq; Tue, 15 Dec 2020 23:24:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2nxe/rq7eUYmjuQhdkAX04lLSSbs8ufQ8D0wZOh9luTl62xKWLA/erfWa+81lBVsbRdUy X-Received: by 2002:a25:860f:: with SMTP id y15mr52909483ybk.83.1608103477878; Tue, 15 Dec 2020 23:24:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608103477; cv=none; d=google.com; s=arc-20160816; b=uENyDwNAWL1wNDWfEkXYrxAe16lYb6eEszMvdsaNms8J2bPjmAXtvppG490bpZh7RQ pHR1kRJbqVZczlbycvalYZQEltUd8A7TraCMtqonJTEVLVblqZGS8Fue/J4vuWPYYPek BCymqs7KmUQw4EcQZgH0UMDOs4DkP1pnW+g+ypq21J8tzEw8kVR6nq7JtTh3qm6dCdA5 1roqrQl2NGSiY7wbetYwj+IQDK0dLT77Ex1l7wf6NJNT8umBAv+Ikx0+duG7FarGEO9x 2NS6WH/LmV0P2SvOSZexBqMgvJChJFS4jAU+uiuWSxk7rAtekupc/gysJWEC8mZxrvU8 LtzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition:in-reply-to :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=HhY7pZAp+jq0qbHXvEw7A+INyJm/1/hBSkcL6a2jzoE=; b=iKghPgsu6JSqSxJcZeh35vIbWTNoAiQYng3mAs5O/OyOFHzuMEwPJImGnNdpuAulnf vLw+NG3Z7yIG2MC/so9SI/tG+OAju2Qs78OiFgv/g2WxBxm9S7IsgnuE65IaNE5dBL+k eQXwj5XAvMUtnQuB3cEQDKU+1BqzUCJ3R4YY6KM3QmVu0313m8wcq1KyBTA4BLCeZuJ1 yafGzuYMlIcoLRrQhY8Trmz0zTjH0q9b5tgJG5x2jvbRAH+QA6mgXkIGgO+P7yBFfEqL 2LNZnMD7VtBmduelMyvLXc808AHw1MiqfrfBxeWTIq8GB77cQMFLBp+9+p1NRlTfBGR5 +Y4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=BsxLBNB+; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t4si557125ybq.1.2020.12.15.23.24.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Dec 2020 23:24:37 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=BsxLBNB+; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:35474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpRAr-0001xu-AY for alex.bennee@linaro.org; Wed, 16 Dec 2020 02:24:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpRAZ-0001wx-LV for qemu-arm@nongnu.org; Wed, 16 Dec 2020 02:24:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53855) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpRAU-0006J4-QQ for qemu-arm@nongnu.org; Wed, 16 Dec 2020 02:24:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608103452; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HhY7pZAp+jq0qbHXvEw7A+INyJm/1/hBSkcL6a2jzoE=; b=BsxLBNB+EXbPP8qu2bkFG6bzbHLgac7enzzv+U6g4UgXEvfhhDY37J9IACr5/eJGz9Ldnf XjJOdWuyPYKcbzQZioUtyABfvbBem0/8CPrHvY5+d4I2a9tK+9PPNtiRNZKGqkcsDNMAFX KIJOAHrDtwcxb0pzAIydFPqbXfd4P4g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-369-Hr_wFm5QM0Su50GXNV2CAA-1; Wed, 16 Dec 2020 02:24:09 -0500 X-MC-Unique: Hr_wFm5QM0Su50GXNV2CAA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6781107AD24; Wed, 16 Dec 2020 07:24:07 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.40.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E19566F926; Wed, 16 Dec 2020 07:24:01 +0000 (UTC) Date: Wed, 16 Dec 2020 08:23:58 +0100 From: Andrew Jones To: Keqian Zhu Subject: Re: [PATCH 2/2] accel: kvm: Add aligment check for kvm_log_clear_one_slot Message-ID: <20201216072358.bmac5twmtoyxcna3@kamzik.brq.redhat.com> References: <20201215071948.23940-1-zhukeqian1@huawei.com> <20201215071948.23940-3-zhukeqian1@huawei.com> <20201215115541.vgbt7aaiueyw7ury@kamzik.brq.redhat.com> MIME-Version: 1.0 In-Reply-To: <20201215115541.vgbt7aaiueyw7ury@kamzik.brq.redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=drjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=drjones@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , jiangkunkun@huawei.com, qemu-devel@nongnu.org, Peter Xu , "Dr . David Alan Gilbert" , qemu-arm@nongnu.org, wanghaibin.wang@huawei.com, Zenghui Yu , Paolo Bonzini Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: mhHGywxHjT6y On Tue, Dec 15, 2020 at 12:55:50PM +0100, Andrew Jones wrote: > On Tue, Dec 15, 2020 at 03:19:48PM +0800, Keqian Zhu wrote: > > The parameters start and size are transfered from QEMU memory > > emulation layer. It can promise that they are TARGET_PAGE_SIZE > > aligned. However, KVM needs they are qemu_real_page_size aligned. > > > > Though no caller breaks this aligned requirement currently, we'd > > better add an explicit check to avoid future breaking. > > > > Signed-off-by: Keqian Zhu > > --- > > accel/kvm/kvm-all.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c > > index c5e06288eb..3d0e3aa872 100644 > > --- a/accel/kvm/kvm-all.c > > +++ b/accel/kvm/kvm-all.c > > @@ -701,6 +701,11 @@ static int kvm_log_clear_one_slot(KVMSlot *mem, int as_id, uint64_t start, > > unsigned long *bmap_clear = NULL, psize = qemu_real_host_page_size; > > int ret; > > > > + /* Make sure start and size are psize aligned */ > > + if (!QEMU_IS_ALIGNED(start, psize) || !QEMU_IS_ALIGNED(size, psize)) { > > + return -EINVAL; > > + } > > + > > /* > > * We need to extend either the start or the size or both to > > * satisfy the KVM interface requirement. Firstly, do the start > > -- > > 2.23.0 > > > > > > It's not clear to me that this function has any restrictions on start > and size. If it does, then please document those restrictions in the > function's header and assert rather than return. > Also, I see this patch is on its way in https://patchwork.ozlabs.org/project/qemu-devel/patch/20201215175445.1272776-27-pbonzini@redhat.com/ Thanks, drew