From nobody Wed Apr 24 06:20:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1562902098; cv=none; d=zoho.com; s=zohoarc; b=iSfcPTgfObQ6UwtkUAUC501Z66YRV05z7uEIsVb81lIQo566AyVG/RPpReSXt7F4aZYMV7K/NER5LWUkK4i788pAixjAB+dio5fZMV69J/ZXrSpYcIYPWLoL29gFmc7PGIKSz41gh4YD3DSCof7NIfcWHTeo81hdfRBvEvrdKSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562902098; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=rlK684/tGG3+ijdtV8oAv7Ytq+Y7L+YsFnreCQ6Q9tk=; b=E6VdNA5ZNCpmTJSp/ubNLewymvMzsfz2uAitWwamjBEzMT4LLMRO13bnFug1D1bR6lzRyJWLVMeZrQj1gDFF75SxaTeL9eciAOH6qTOsP191v8hAUBmL2XuwPgC8wk+VUg1Z18Uk1hWxcg13of/cQGz4D2GTLO70PjMwg/HXrVQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1562902098049800.7909740414752; Thu, 11 Jul 2019 20:28:18 -0700 (PDT) Received: from localhost ([::1]:46434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlmEG-0007af-CT for importer@patchew.org; Thu, 11 Jul 2019 23:28:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59380) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlmE4-00073H-Cj for qemu-devel@nongnu.org; Thu, 11 Jul 2019 23:28:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hlmE3-0007WJ-FA for qemu-devel@nongnu.org; Thu, 11 Jul 2019 23:28:00 -0400 Received: from mga14.intel.com ([192.55.52.115]:47307) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hlmE3-0007UP-75 for qemu-devel@nongnu.org; Thu, 11 Jul 2019 23:27:59 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2019 20:27:56 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga007.jf.intel.com with ESMTP; 11 Jul 2019 20:27:54 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,480,1557212400"; d="scan'208";a="157018697" From: Wei Yang To: qemu-devel@nongnu.org Date: Fri, 12 Jul 2019 11:27:04 +0800 Message-Id: <20190712032704.7826-1-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH] migration: check length directly to make sure the range is aligned X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Wei Yang , rth@twiddle.net, dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since the start addr is already checked, to make sure the range is aligned, checking the length is enough. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert --- exec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/exec.c b/exec.c index 50ea9c5aaa..8fa980baae 100644 --- a/exec.c +++ b/exec.c @@ -4067,10 +4067,9 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t s= tart, size_t length) =20 if ((start + length) <=3D rb->used_length) { bool need_madvise, need_fallocate; - uint8_t *host_endaddr =3D host_startaddr + length; - if ((uintptr_t)host_endaddr & (rb->page_size - 1)) { - error_report("ram_block_discard_range: Unaligned end address: = %p", - host_endaddr); + if (length & (rb->page_size - 1)) { + error_report("ram_block_discard_range: Unaligned length: %lx", + length); goto err; } =20 --=20 2.17.1