Skip to content

Commit

Permalink
Squashed 'security' changes from c161ed9..c35483a (#702)
Browse files Browse the repository at this point in the history
c35483a Merge pull request Xilinx#179 from liyuanz/next
dfc3cd2 fix description.json (Xilinx#180)
7f4febd update mk
53416f6 fix error in allocation pragma (Xilinx#178)
8ef77fa 2022.2 HMAC-SHA384 2in1 and ECDSA NIST P-384 (Xilinx#177)
489a68f add poseidon252 kernel and testcase (Xilinx#174)
bf96fd0 fix typo in tutorial.rst (Xilinx#176)
4e9d830 Merge pull request Xilinx#172 from yuanqian/update_doc_next
386656d fix bug
2ced06d fix description.json, remove vck190 from platform_property (Xilinx#175)
9118e6d missing vitis_hw_build (Xilinx#166)
d22b630 update
bdf2371 Merge pull request Xilinx#173 from liyuanz/next
dd3a1fb add mem
518370f update doc in next branch for porta;
f2b1ce6 Merge pull request Xilinx#171 from liyuanz/next
e4416f7 update mk
e735446 Merge pull request Xilinx#168 from changg/22.2_mks
a9b9570 Merge pull request Xilinx#167 from giorgiob/patch-2
8bd73a7 22.2 mk update
e1df4e8 u2_ platform name update
4715bf5 change 2022.1_stable_latest to 2022.2_stable_latest
c616562 fix typos in tutorial (Xilinx#163)

Co-authored-by: sdausr <[email protected]>
  • Loading branch information
2 people authored and GitHub Enterprise committed Sep 16, 2022
1 parent 5788af7 commit 31907cf
Show file tree
Hide file tree
Showing 169 changed files with 7,231 additions and 457 deletions.
2 changes: 1 addition & 1 deletion security/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('pipeline-library')_
VitisLibPipeline (branch: 'next', libname: 'xf_security', TARGETS: 'hls_csim:hls_cosim:vivado_syn:vitis_sw_emu:vitis_hw_emu:vitis_hw_build',
upstream_dependencies: 'xf_utils_hw,next,../utils',
devtest: 'RunDeploy.sh', TOOLVERSION: '2022.1_stable_latest', mail_on:'daily:PR')
devtest: 'RunDeploy.sh', TOOLVERSION: '2022.2_stable_latest', mail_on:'daily:PR')
95 changes: 60 additions & 35 deletions security/L1/benchmarks/adler32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# vitis makefile-generator v2.0.6
# vitis makefile-generator v2.0.7

############################## Help Section ##############################
.PHONY: help
Expand All @@ -34,9 +34,15 @@ help::
$(ECHO) " Command to build host application."
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH is required for SoC shells"
$(ECHO) ""
$(ECHO) " NOTE: For embedded devices, e.g. zcu102/zcu104/vck190, env variable SYSROOT and EDGE_COMMON_SW need to be set first, and HOST_ARCH is either aarch32 or aarch64. For example,"
$(ECHO) " export SYSROOT=< path-to-platform-sysroot >"
$(ECHO) " export EDGE_COMMON_SW=< path-to-rootfs-and-Image-files >"
$(ECHO) " NOTE: For embedded devices, e.g. zcu102/zcu104/vck190, HOST_ARCH is either aarch32 or aarch64."
$(ECHO) " a.IF Download the platform, and common-image from Xilinx Download Center(Suggested):"
$(ECHO) " Run the sdk.sh script from the common-image directory to install sysroot using the command : ./sdk.sh -y -d ./ -p "
$(ECHO) " Unzip the rootfs file : gunzip ./rootfs.ext4.gz"
$(ECHO) " export SYSROOT=< path-to-platform-sysroot >"
$(ECHO) " b. User could also define SYSROOT, K_IMAGE and ROOTFS by themselves: "
$(ECHO) " export SYSROOT=< path-to-platform-sysroot >"
$(ECHO) " export K_IMAGE=< path-to-Image-files >"
$(ECHO) " export ROOTFS=< path-to-rootfs >"
$(ECHO) ""
$(ECHO) " make clean "
$(ECHO) " Command to remove the generated non-hardware files."
Expand Down Expand Up @@ -87,12 +93,17 @@ RUN_DEPS :=
# get global setting
ifeq ($(HOST_ARCH), x86)
CXXFLAGS += -fmessage-length=0 -I$(CUR_DIR)/src/ -I$(XILINX_XRT)/include -I$(XILINX_HLS)/include -std=c++14 -O3 -Wall -Wno-unknown-pragmas -Wno-unused-label
LDFLAGS += -pthread -L$(XILINX_XRT)/lib -L$(XILINX_HLS)/lnx64/tools/fpo_v7_0 -Wl,--as-needed -lOpenCL -lxrt_coreutil -lgmp -lmpfr -lIp_floating_point_v7_0_bitacc_cmodel
LDFLAGS += -pthread -L$(XILINX_XRT)/lib -L$(XILINX_HLS)/lnx64/tools/fpo_v7_1 -Wl,--as-needed -lOpenCL -lxrt_coreutil -lgmp -lmpfr -lIp_floating_point_v7_1_bitacc_cmodel
VPP_FLAGS += -t $(TARGET) --platform $(XPLATFORM) --save-temps
VPP_LDFLAGS += --optimize 2 -R 2
else ifeq ($(HOST_ARCH), aarch64)
ifeq ($(ps_on_x86), true)
CXXFLAGS += -fmessage-length=0 -I$(CUR_DIR)/src/ -I$(XILINX_XRT)/include -I$(XILINX_HLS)/include -std=c++14 -O3 -Wall -Wno-unknown-pragmas -Wno-unused-label
LDFLAGS += -pthread -L$(XILINX_XRT)/lib -L$(XILINX_HLS)/lnx64/tools/fpo_v7_1 -Wl,--as-needed -lOpenCL -lxrt_coreutil -lgmp -lmpfr -lIp_floating_point_v7_1_bitacc_cmodel
else
CXXFLAGS += -I$(CUR_DIR)/src/ -fmessage-length=0 --sysroot=$(SYSROOT) -I$(SYSROOT)/usr/include/xrt -I$(XILINX_HLS)/include -std=c++14 -O3 -Wall -Wno-unknown-pragmas -Wno-unused-label
LDFLAGS += -pthread -L$(SYSROOT)/usr/lib -L$(XILINX_VITIS_AIETOOLS)/lib/aarch64.o -Wl,--as-needed -lxilinxopencl -lxrt_coreutil
LDFLAGS += -pthread -L$(SYSROOT)/usr/lib -Wl,--as-needed -lxilinxopencl -lxrt_coreutil
endif
VPP_FLAGS += -t $(TARGET) --platform $(XPLATFORM) --save-temps
VPP_LDFLAGS += --optimize 2 -R 2
endif
Expand All @@ -107,14 +118,21 @@ ifeq ($(TARGET),hw_emu)
CXXFLAGS += -D HW_EMU_TEST
endif

ifeq (,$(findstring opencv,$(CXXFLAGS)))
CXXFLAGS += $(XRT_CXXFLAGS)
endif

#Inclue Required Host Source Files
ifeq ($(ps_on_x86), true)
HOST_SRCS += $(XFLIB_DIR)/L1/benchmarks/adler32/host/main.cpp $(XFLIB_DIR)/ext/xcl2/xcl2.cpp
CXXFLAGS += -I $(XFLIB_DIR)/L1/include -I $(XFLIB_DIR)/L1/benchmarks/adler32/host -I $(XFLIB_DIR)/L1/benchmarks/adler32/kernel -I $(XFLIB_DIR)/ext/xcl2 -I $(XFLIB_DIR)/../utils/L1/include -I $(XFLIB_DIR)/ext/xcl2
CXXFLAGS += -I $(XFLIB_DIR)/L1/include -I $(XFLIB_DIR)/L1/benchmarks/adler32/host -I $(XFLIB_DIR)/L1/benchmarks/adler32/kernel -I $(XFLIB_DIR)/ext/xcl2 -I $(XFLIB_DIR)/../utils/L1/include -I $(XFLIB_DIR)/ext/xcl2 -I $(XFLIB_DIR)/ext/xcl2
CXXFLAGS += -O3
else
HOST_SRCS += $(XFLIB_DIR)/L1/benchmarks/adler32/host/main.cpp $(XFLIB_DIR)/ext/xcl2/xcl2.cpp
CXXFLAGS += -I $(XFLIB_DIR)/L1/include -I $(XFLIB_DIR)/L1/benchmarks/adler32/host -I $(XFLIB_DIR)/L1/benchmarks/adler32/kernel -I $(XFLIB_DIR)/ext/xcl2 -I $(XFLIB_DIR)/../utils/L1/include -I $(XFLIB_DIR)/ext/xcl2 -I $(XFLIB_DIR)/ext/xcl2
CXXFLAGS += -O3
endif

# workaround for opencv
ifeq (,$(findstring opencv,$(CXXFLAGS)))
CXXFLAGS += $(XRT_CXXFLAGS)
endif

EXE_NAME := host.exe
EXE_FILE := $(BUILD_DIR)/$(EXE_NAME)
Expand Down Expand Up @@ -154,7 +172,7 @@ endif
$(TEMP_DIR)/Adler32Kernel.xo: $(XFLIB_DIR)/L1/benchmarks/adler32/kernel/adler32_kernel.cpp
$(ECHO) "Compiling Kernel: Adler32Kernel"
mkdir -p $(TEMP_DIR)
$(VPP) -c $(VPP_FLAGS_Adler32Kernel) $(VPP_FLAGS) -k Adler32Kernel -I'$(<D)' --temp_dir $(TEMP_DIR) --report_dir $(TEMP_REPORT_DIR) -o'$@' '$^'
$(VPP) -c $(VPP_FLAGS_Adler32Kernel) $(VPP_FLAGS) -k Adler32Kernel -I'$(<D)' --temp_dir $(TEMP_DIR) --report_dir $(TEMP_REPORT_DIR) -o $@ $^
BINARY_CONTAINER_Adler32Kernel_OBJS += $(TEMP_DIR)/Adler32Kernel.xo
BINARY_CONTAINERS_DEPS += $(BINARY_CONTAINER_Adler32Kernel_OBJS)
$(BINARY_CONTAINERS): $(BINARY_CONTAINERS_DEPS)
Expand All @@ -178,11 +196,6 @@ $(EMCONFIG):
emconfigutil --platform $(XPLATFORM) --od $(BUILD_DIR)
############################## Preparing sdcard folder ##############################
ifneq ($(HOST_ARCH), x86)
ifneq (,$(findstring zc706, $(PLATFORM_NAME)))
K_IMAGE := $(SYSROOT)/../../uImage
else
K_IMAGE := $(SYSROOT)/../../Image
endif
RUN_SCRIPT := $(BUILD_DIR)/run_script.sh
$(RUN_SCRIPT):
rm -rf $(RUN_SCRIPT)
Expand All @@ -198,7 +211,7 @@ endif
@echo './$(EXE_NAME) $(PKG_HOST_ARGS)' >> $(RUN_SCRIPT)
@echo 'return_code=$$?' >> $(RUN_SCRIPT)
@echo 'if [ $$return_code -ne 0 ]; then' >> $(RUN_SCRIPT)
@echo ' echo "ERROR: Embedded host run failed, RC=$$return_code"' >> $(RUN_SCRIPT)
@echo ' echo "ERROR: TEST FAILED, RC=$$return_code"' >> $(RUN_SCRIPT)
@echo 'else' >> $(RUN_SCRIPT)
@echo ' echo "INFO: TEST PASSED, RC=0"' >> $(RUN_SCRIPT)
@echo 'fi' >> $(RUN_SCRIPT)
Expand All @@ -216,23 +229,28 @@ SD_DIRS_WITH_PREFIX = $(foreach sd_dir,$(DATA_DIR),--package.sd_dir $(sd_dir))
PACKAGE_FILES := $(BINARY_CONTAINERS)
PACKAGE_FILES += $(AIE_CONTAINER)
SD_CARD := $(CUR_DIR)/package_$(TARGET)
vck190_dfx_hw := false
$(SD_CARD): $(EXE_FILE) $(BINARY_CONTAINERS) $(RUN_SCRIPT) $(EMCONFIG)
$(SD_CARD): $(EXE_FILE) $(BINARY_CONTAINERS) $(RUN_SCRIPT) $(EMCONFIG) check_kimage check_rootfs
@echo "Generating sd_card folder...."
mkdir -p $(SD_CARD)
chmod a+rx $(BUILD_DIR)/run_script.sh
ifneq (,$(findstring vck190_base_dfx, $(PLATFORM_NAME)))
ifeq ($(TARGET),hw)
$(VPP) -t $(TARGET) --platform $(XPLATFORM) -p $(PACKAGE_FILES) -o $(BINARY_CONTAINERS_PKG)
$(VPP) -t $(TARGET) --platform $(XPLATFORM) -p --package.out_dir $(SD_CARD) --package.rootfs $(SYSROOT)/../../rootfs.ext4 --package.kernel_image $(K_IMAGE) $(SD_FILES_WITH_PREFIX) $(SD_DIRS_WITH_PREFIX) --package.sd_file $(BINARY_CONTAINERS_PKG)
# 1. DFX HW Flow
ifeq ($(dfx_hw), true)
$(VPP) -t $(TARGET) --platform $(XPLATFORM) -p $(PACKAGE_FILES) $(VPP_PACKAGE) -o $(BINARY_CONTAINERS_PKG)
$(VPP) -t $(TARGET) --platform $(XPLATFORM) -p --package.out_dir $(SD_CARD) --package.rootfs $(ROOTFS) --package.kernel_image $(K_IMAGE) $(SD_FILES_WITH_PREFIX) $(SD_DIRS_WITH_PREFIX) --package.sd_file $(BINARY_CONTAINERS_PKG)
@echo "### ***** sd_card generation done! ***** ###"
vck190_dfx_hw := true
endif
# 2. PS_ON_X86 - From 2022.2, Target:sw_emu
ifeq ($(ps_on_x86), true)
@echo "### ***** running PS X86 SE_EMU ***** ###"
$(VPP) -t $(TARGET) --platform $(XPLATFORM) -o $(BINARY_CONTAINERS_PKG) -p $(PACKAGE_FILES) $(VPP_PACKAGE) --package.out_dir $(SD_CARD) --package.emu_ps x86
endif
ifeq ($(vck190_dfx_hw), false)
$(VPP) -t $(TARGET) --platform $(XPLATFORM) -o $(BINARY_CONTAINERS_PKG) -p $(PACKAGE_FILES) $(VPP_PACKAGE) --package.out_dir $(SD_CARD) --package.rootfs $(SYSROOT)/../../rootfs.ext4 --package.kernel_image $(K_IMAGE) $(SD_FILES_WITH_PREFIX) $(SD_DIRS_WITH_PREFIX)
#3. General Embeded flow
ifeq ($(dfx_hw), false)
ifeq ($(ps_on_x86), false)
$(VPP) -t $(TARGET) --platform $(XPLATFORM) -o $(BINARY_CONTAINERS_PKG) -p $(PACKAGE_FILES) $(VPP_PACKAGE) --package.out_dir $(SD_CARD) --package.rootfs $(ROOTFS) --package.kernel_image $(K_IMAGE) $(SD_FILES_WITH_PREFIX) $(SD_DIRS_WITH_PREFIX)
@echo "### ***** sd_card generation done! ***** ###"
endif
endif

.PHONY: sd_card
sd_card: $(SD_CARD)
Expand All @@ -256,7 +274,7 @@ ifeq ($(HOST_ARCH), x86)

else
@echo $(RUN_DEPS)
$(SD_CARD)/launch_$(TARGET).sh -no-reboot -run-app $(notdir $(RUN_SCRIPT))
$(SD_CARD)/launch_$(TARGET).sh -no-reboot -run-app $(notdir $(RUN_SCRIPT)) 2>&1 | tee $(SD_CARD)/qemu_output.log
grep "TEST PASSED, RC=0" $(SD_CARD)/qemu_output.log || exit 1

endif
Expand All @@ -267,24 +285,32 @@ ifeq ($(HOST_ARCH), x86)
LD_LIBRARY_PATH=$(LIBRARY_PATH):$$LD_LIBRARY_PATH \
XCL_EMULATION_MODE=$(TARGET) $(EXE_FILE) $(HOST_ARGS)

else
ifeq ($(ps_on_x86), true)
LD_LIBRARY_PATH=$(LIBRARY_PATH):$$LD_LIBRARY_PATH \
XCL_EMULATION_MODE=$(TARGET) $(EXE_FILE) $(HOST_ARGS)

else
@echo $(RUN_DEPS)
$(SD_CARD)/launch_$(TARGET).sh -no-reboot -run-app $(notdir $(RUN_SCRIPT))
$(SD_CARD)/launch_$(TARGET).sh -no-reboot -run-app $(notdir $(RUN_SCRIPT)) 2>&1 | tee $(SD_CARD)/qemu_output.log
grep "TEST PASSED, RC=0" $(SD_CARD)/qemu_output.log || exit 1

endif
endif
endif
#hw
ifeq ($(TARGET), hw)
ifneq (,$(findstring aws-vu9p-f1, $(PLATFORM_NAME)))
ifneq ($(JENKINS_INTERNAL_BUILD), 1)
ifeq (,$(wildcard $(BUILD_DIR)/Adler32Kernel.awsxclbin))
$(ECHO) "This makefile does not directly support converting .xclbin to .awsxclbin, please refer https://github.com/aws/aws-fpga/blob/master/Vitis/README.md for next operations"
else
$(ECHO) "Running inside Xilinx regression without converting to .awsxclbin"
$(EXE_FILE) $(HOST_ARGS)
$(ECHO) "Running HW using generated .awsxclbin"
LD_LIBRARY_PATH=$(LIBRARY_PATH):$$LD_LIBRARY_PATH \
$(EXE_FILE) $(subst .xclbin,.awsxclbin,$(HOST_ARGS))

endif
else ifeq ($(HOST_ARCH), x86)
LD_LIBRARY_PATH=$(LIBRARY_PATH):$$LD_LIBRARY_PATH \
$(EXE_FILE) $(HOST_ARGS)

else
Expand Down Expand Up @@ -318,12 +344,11 @@ cleanh:

cleank:
-$(RMDIR) $(BUILD_DIR)/*.xclbin _vimage *xclbin.run_summary qemu-memory-_* emulation/ _vimage/ pl*start_simulation. sh *.xclbin
-$(RMDIR) _x_temp.*/_x.* _x_temp.*/.Xil _x_temp.*/profile_summary.* xo_* _x*
-$(RMDIR) _x_temp.*/dltmp* _x_temp.*/kernel_info.dat _x_temp.*/*.log
-$(RMDIR) _x_temp.*
-$(RMDIR) _x_temp.*

cleanall: cleanh cleank
-$(RMDIR) $(BUILD_DIR) emconfig.json *.html $(TEMP_DIR) $(CUR_DIR)/reports *.csv *.run_summary $(CUR_DIR)/*.raw package_* $(BUILD_DIR)/run_script.sh .ipcache *.str
-$(RMDIR) $(CUR_DIR)/Work $(CUR_DIR)/*.xpe $(CUR_DIR)/hw.o $(CUR_DIR)/*.xsa $(CUR_DIR)/xnwOut
-$(RMDIR)

clean: cleanh
62 changes: 56 additions & 6 deletions security/L1/benchmarks/adler32/utils.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# vitis makefile-generator v2.0.6
# vitis makefile-generator v2.0.7
#
#+-------------------------------------------------------------------------------
# The following parameters are assigned with default values. These parameters can
Expand Down Expand Up @@ -50,6 +50,7 @@ ifndef XILINX_XRT
export XILINX_XRT
endif

.PHONY: check_device
check_device:
@set -eu; \
inallowlist=False; \
Expand Down Expand Up @@ -82,8 +83,9 @@ endif
endif


#get suffix of kernel by PLATFORM
# Special processing for tool version/platform type
VITIS_VER = $(shell v++ --version | grep 'v++' | sed 's/^[[:space:]]*//' | sed -e 's/^[*]* v++ v//g' | cut -d " " -f1)
# 1) for versal flow from 2022.1
DEVICE_TYPE = $(shell platforminfo -p $(PLATFORM) | grep 'FPGA Family' | sed 's/.*://' | sed '/ai_engine/d' | sed 's/^[[:space:]]*//')
ifeq ($(DEVICE_TYPE), versal)
ifeq ($(shell expr $(VITIS_VER) \>= 2022.1), 1)
Expand All @@ -94,6 +96,22 @@ endif
else
LINK_TARGET_FMT := xclbin
endif
# 2) dfx flow
dfx_hw := false
ifeq ($(findstring _dfx_, $(PLATFORM_NAME)),_dfx_)
ifeq ($(TARGET),hw)
dfx_hw := true
endif
endif
# 3) for embeded sw_emu flow from 2022.2
ps_on_x86 := false
ifneq ($(HOST_ARCH), x86)
ifeq ($(shell expr $(VITIS_VER) \>= 2022.2), 1)
ifeq ($(TARGET), sw_emu)
ps_on_x86 := true
endif
endif
endif

#Checks for Device Family
ifeq ($(HOST_ARCH), aarch32)
Expand All @@ -107,24 +125,54 @@ ifneq ($(HOST_ARCH), $(filter $(HOST_ARCH),aarch64 aarch32 x86))
$(error HOST_ARCH variable not set, please set correctly and rerun)
endif

.PHONY: check_version check_sysroot check_kimage check_rootfs
check_version:
ifneq (, $(shell which git))
ifneq (,$(wildcard $(XFLIB_DIR)/.git))
@cd $(XFLIB_DIR) && git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -n 1 && cd -
endif
endif

#Checks for SYSROOT
#Set/Check SYSROOT/K_IMAGE/ROOTFS
ifneq ($(HOST_ARCH), x86)
ifneq (,$(findstring zc706, $(PLATFORM_NAME)))
K_IMAGE ?= $(SYSROOT)/../../uImage
else
K_IMAGE ?= $(SYSROOT)/../../Image
endif
ROOTFS ?= $(SYSROOT)/../../rootfs.ext4
endif

check_sysroot:
ifneq ($(HOST_ARCH), x86)
ifndef SYSROOT
ifeq (,$(wildcard $(SYSROOT)))
$(error SYSROOT ENV variable is not set, please set ENV variable correctly and rerun)
endif
endif
check_kimage:
ifneq ($(HOST_ARCH), x86)
ifeq (,$(wildcard $(K_IMAGE)))
$(error K_IMAGE ENV variable is not set, please set ENV variable correctly and rerun)
endif
endif
check_rootfs:
ifneq ($(HOST_ARCH), x86)
ifeq (,$(wildcard $(ROOTFS)))
$(error ROOTFS ENV variable is not set, please set ENV variable correctly and rerun)
endif
endif

#Checks for g++
CXX := g++
ifeq ($(HOST_ARCH), x86)
X86_CXX := true
else
ifeq ($(ps_on_x86), true)
X86_CXX := true
endif
endif

CXX := g++
ifeq ($(X86_CXX), true)
ifeq ($(shell expr $(VITIS_VER) \>= 2022.1), 1)
CXX_VER := 8.3.0
else
Expand All @@ -144,11 +192,13 @@ endif
$(warning [WARNING]: g++ version too old. Using g++ provided by the tool: $(CXX))
endif
endif
else ifeq ($(HOST_ARCH), aarch64)
else
ifeq ($(HOST_ARCH), aarch64)
CXX := $(XILINX_VITIS)/gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-g++
else ifeq ($(HOST_ARCH), aarch32)
CXX := $(XILINX_VITIS)/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-g++
endif
endif

#Check OS and setting env for xrt c++ api
OSDIST = $(shell lsb_release -i |awk -F: '{print tolower($$2)}' | tr -d ' \t' )
Expand Down
Loading

0 comments on commit 31907cf

Please sign in to comment.