From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web12.27079.1658150325580236005 for ; Mon, 18 Jul 2022 06:18:46 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=fK0j7nrr; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658150326; x=1689686326; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qtKh7p+TIAF+LfXitBrtoU/c1Kl3Hk7pypaZ2xCpbTU=; b=fK0j7nrr49xaWJleeWEhO1diZTUQLsoopnoRSQm3YvKqI/IpkwzHNktf eNwXu3cXWAaLkmWmU2GCX5T6MQrEHgXCx1EDQ2LVlAuxU1+CBlmZ4Ee3s lkFys+iOr0McNwCry4gUBV9CcK3f5Dr8W08i4QDmTwr6HtpHT8Dyf2ndH O308eJIomEObNktWD1Enzr+EQyr/bc7NHmEtG1LEKA+oFD/WEBaOZ3K1N U4Qpd0N94Fu5rwO156eILaD0ys8r/UcbNYkEDGS5wDXj49JpNsAYQ7Pjh S5Yuzb1MqQ/DLMRQcXnxt4H8S+Ebvy9Ek7RuAvVbU3+oyn3Y80SSfrJ7o A==; X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="287363888" X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="287363888" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 06:18:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="624724957" Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.183.102]) by orsmga008.jf.intel.com with ESMTP; 18 Jul 2022 06:18:41 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Zhiguang Liu , Eric Dong Subject: [PATCH 02/10] UefiCpuPkg/CpuPageTableLib: Return error on invalid parameters Date: Mon, 18 Jul 2022 21:18:23 +0800 Message-Id: <20220718131831.660-3-ray.ni@intel.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20220718131831.660-1-ray.ni@intel.com> References: <20220718131831.660-1-ray.ni@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable When LinearAddress or Length is not aligned on 4KB, PageTableMap() should return Invalid Parameter. Signed-off-by: Zhiguang Liu Reviewed-by: Ray Ni Cc: Eric Dong --- UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c b/UefiCpu= Pkg/Library/CpuPageTableLib/CpuPageTableMap.c index 25e13a6f6f..17bca5e351 100644 --- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c +++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c @@ -467,6 +467,13 @@ PageTableMap ( return RETURN_INVALID_PARAMETER;=0D }=0D =0D + if ((LinearAddress % SIZE_4KB !=3D 0) || (Length % SIZE_4KB !=3D 0)) {=0D + //=0D + // LinearAddress and Length should be multiple of 4K.=0D + //=0D + return RETURN_INVALID_PARAMETER;=0D + }=0D +=0D if ((*BufferSize !=3D 0) && (Buffer =3D=3D NULL)) {=0D return RETURN_INVALID_PARAMETER;=0D }=0D --=20 2.35.1.windows.2