From eae331fe2943cc40e462f35f2dc0055e41788635 Mon Sep 17 00:00:00 2001 From: Roman Kubiak Date: Tue, 12 Apr 2016 14:41:30 +0900 Subject: [PATCH 01/16] netfilter: nfnetlink_queue: add security context information This patch adds an additional attribute when sending packet information via netlink in netfilter_queue module. It will send additional security context data, so that userspace applications can verify this context against their own security databases. Change-Id: I1f8e8bea84e05abfc78808f6fccc513aa5bb0a9f Signed-off-by: Roman Kubiak Acked-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: jooseong lee --- include/uapi/linux/netfilter/nfnetlink_queue.h | 4 ++- net/netfilter/nfnetlink_queue_core.c | 35 +++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/netfilter/nfnetlink_queue.h b/include/uapi/linux/netfilter/nfnetlink_queue.h index 22f5d45..048e4ef 100644 --- a/include/uapi/linux/netfilter/nfnetlink_queue.h +++ b/include/uapi/linux/netfilter/nfnetlink_queue.h @@ -49,6 +49,7 @@ enum nfqnl_attr_type { NFQA_EXP, /* nf_conntrack_netlink.h */ NFQA_UID, /* __u32 sk uid */ NFQA_GID, /* __u32 sk gid */ + NFQA_SECCTX, /* security context string */ __NFQA_MAX }; @@ -102,7 +103,8 @@ enum nfqnl_attr_config { #define NFQA_CFG_F_CONNTRACK (1 << 1) #define NFQA_CFG_F_GSO (1 << 2) #define NFQA_CFG_F_UID_GID (1 << 3) -#define NFQA_CFG_F_MAX (1 << 4) +#define NFQA_CFG_F_SECCTX (1 << 4) +#define NFQA_CFG_F_MAX (1 << 5) /* flags for NFQA_SKB_INFO */ /* packet appears to have wrong checksums, but they are ok */ diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c index dabd68a..c9c69f6 100644 --- a/net/netfilter/nfnetlink_queue_core.c +++ b/net/netfilter/nfnetlink_queue_core.c @@ -318,6 +318,23 @@ nla_put_failure: return -1; } +static u32 nfqnl_get_sk_secctx(struct sk_buff *skb, char **secdata) +{ + u32 seclen = 0; +#if IS_ENABLED(CONFIG_NETWORK_SECMARK) + if (skb->sk->sk_state == TCP_TIME_WAIT) + return 0; + + read_lock_bh(&skb->sk->sk_callback_lock); + + if (skb->secmark) + security_secid_to_secctx(skb->secmark, secdata, &seclen); + + read_unlock_bh(&skb->sk->sk_callback_lock); +#endif + return seclen; +} + static struct sk_buff * nfqnl_build_packet_message(struct nfqnl_instance *queue, struct nf_queue_entry *entry, @@ -336,6 +353,8 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, struct net_device *outdev; struct nf_conn *ct = NULL; enum ip_conntrack_info uninitialized_var(ctinfo); + char *secdata = NULL; + u32 seclen = 0; size = nlmsg_total_size(sizeof(struct nfgenmsg)) + nla_total_size(sizeof(struct nfqnl_msg_packet_hdr)) @@ -392,6 +411,12 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, + nla_total_size(sizeof(u_int32_t))); /* gid */ } + if ((queue->flags & NFQA_CFG_F_SECCTX) && entskb->sk) { + seclen = nfqnl_get_sk_secctx(entskb, &secdata); + if (seclen) + size += nla_total_size(seclen); + } + skb = nfnetlink_alloc_skb(&init_net, size, queue->peer_portid, GFP_ATOMIC); if (!skb) { @@ -508,6 +533,9 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, nfqnl_put_sk_uidgid(skb, entskb->sk) < 0) goto nla_put_failure; + if (seclen && nla_put(skb, NFQA_SECCTX, seclen, secdata)) + goto nla_put_failure; + if (ct && nfqnl_ct_put(skb, ct, ctinfo) < 0) goto nla_put_failure; @@ -1179,7 +1207,12 @@ nfqnl_recv_config(struct sock *ctnl, struct sk_buff *skb, ret = -EOPNOTSUPP; goto err_out_unlock; } - +#if !IS_ENABLED(CONFIG_NETWORK_SECMARK) + if (flags & mask & NFQA_CFG_F_SECCTX) { + ret = -EOPNOTSUPP; + goto err_out_unlock; + } +#endif spin_lock_bh(&queue->lock); queue->flags &= ~mask; queue->flags |= flags & mask; -- 2.7.4 From 9a1eb70d7f377245f2c19fce643151646354eb8c Mon Sep 17 00:00:00 2001 From: jooseong lee Date: Tue, 3 May 2016 19:40:36 +0900 Subject: [PATCH 02/16] ARM: tizen_tm1_defconfig: enable netfilter_audit and smack_netfilter This patch enables smack netfilter to support nether serivce. Nether is for network access control in Tizen3.0. Change-Id: I011f5b2a51583d493d4d5bbc6f7165782b468913 Signed-off-by: jooseong lee --- arch/arm/configs/tizen_tm1_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/configs/tizen_tm1_defconfig b/arch/arm/configs/tizen_tm1_defconfig index b597df9..86bc0ab 100755 --- a/arch/arm/configs/tizen_tm1_defconfig +++ b/arch/arm/configs/tizen_tm1_defconfig @@ -742,7 +742,7 @@ CONFIG_NETFILTER_XT_CONNMARK=y # # Xtables targets # -# CONFIG_NETFILTER_XT_TARGET_AUDIT is not set +CONFIG_NETFILTER_XT_TARGET_AUDIT=y # CONFIG_NETFILTER_XT_TARGET_CHECKSUM is not set CONFIG_NETFILTER_XT_TARGET_CLASSIFY=y CONFIG_NETFILTER_XT_TARGET_CONNMARK=y @@ -3427,6 +3427,7 @@ CONFIG_SECURITY_NETWORK=y # CONFIG_SECURITY_PATH is not set # CONFIG_SECURITY_SELINUX is not set CONFIG_SECURITY_SMACK=y +CONFIG_SECURITY_SMACK_NETFILTER=y # CONFIG_SECURITY_TOMOYO is not set # CONFIG_SECURITY_APPARMOR is not set # CONFIG_SECURITY_YAMA is not set -- 2.7.4 From 823a78b5f4e7fa87adf850981dd8612fb720ea49 Mon Sep 17 00:00:00 2001 From: "Charles (Chas) Williams" Date: Tue, 16 Aug 2016 16:50:11 -0400 Subject: [PATCH 03/16] tcp: make challenge acks less predictable commit 75ff39ccc1bd5d3c455b6822ab09e533c551f758 upstream. From: Eric Dumazet Yue Cao claims that current host rate limiting of challenge ACKS (RFC 5961) could leak enough information to allow a patient attacker to hijack TCP sessions. He will soon provide details in an academic paper. This patch increases the default limit from 100 to 1000, and adds some randomization so that the attacker can no longer hijack sessions without spending a considerable amount of probes. Based on initial analysis and patch from Linus. Note that we also have per socket rate limiting, so it is tempting to remove the host limit in the future. v2: randomize the count of challenge acks per second, not the period. Fixes: 282f23c6ee34 ("tcp: implement RFC 5961 3.2") Reported-by: Yue Cao Signed-off-by: Eric Dumazet Suggested-by: Linus Torvalds Cc: Yuchung Cheng Cc: Neal Cardwell Acked-by: Neal Cardwell Acked-by: Yuchung Cheng Signed-off-by: David S. Miller [ ciwillia: backport to 3.10-stable ] Signed-off-by: Chas Williams Signed-off-by: Willy Tarreau [Apply from linux-3.10.y to fix CVE-2016-5696] Signed-off-by: Seung-Woo Kim Change-Id: Ida4b2baa58464341147f2ef082c6c6002f9c799a --- net/ipv4/tcp_input.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 7aa7faa..d22f062 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -87,7 +88,7 @@ int sysctl_tcp_adv_win_scale __read_mostly = 1; EXPORT_SYMBOL(sysctl_tcp_adv_win_scale); /* rfc5961 challenge ack rate limiting */ -int sysctl_tcp_challenge_ack_limit = 100; +int sysctl_tcp_challenge_ack_limit = 1000; int sysctl_tcp_stdurg __read_mostly; int sysctl_tcp_rfc1337 __read_mostly; @@ -3288,12 +3289,19 @@ static void tcp_send_challenge_ack(struct sock *sk) static u32 challenge_timestamp; static unsigned int challenge_count; u32 now = jiffies / HZ; + u32 count; if (now != challenge_timestamp) { + u32 half = (sysctl_tcp_challenge_ack_limit + 1) >> 1; + challenge_timestamp = now; - challenge_count = 0; + ACCESS_ONCE(challenge_count) = half + + reciprocal_divide(prandom_u32(), + sysctl_tcp_challenge_ack_limit); } - if (++challenge_count <= sysctl_tcp_challenge_ack_limit) { + count = ACCESS_ONCE(challenge_count); + if (count > 0) { + ACCESS_ONCE(challenge_count) = count - 1; NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPCHALLENGEACK); tcp_send_ack(sk); } -- 2.7.4 From e1eb3b23517951039d3776b2db49aa559b7101e4 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Mon, 29 Aug 2016 19:15:29 +0900 Subject: [PATCH 04/16] packaging: remove not used release type build parameter There is not build parameter about release type, and it does not really fix anything. So this patch removes not used release type build parameter from packaging spec file. Change-Id: I930e9beff52ce884f5676da93dbfe847f0fff576 Signed-off-by: Seung-Woo Kim --- packaging/linux-3.10-sc7730.spec | 7 +------ release_obs.sh | 13 +------------ 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/packaging/linux-3.10-sc7730.spec b/packaging/linux-3.10-sc7730.spec index 21ae0a8..6a5497c 100644 --- a/packaging/linux-3.10-sc7730.spec +++ b/packaging/linux-3.10-sc7730.spec @@ -98,18 +98,13 @@ This package provides kernel license file. %setup -q %build -%if 0%{?tizen_build_binary_release_type_eng} -%define RELEASE_TYPE ENG -%else -%define RELEASE_TYPE USR -%endif for i in %{BOARDS}; do target=$i mkdir -p %_builddir/mod_$target make distclean - ./release_obs.sh $target %{RELEASE_TYPE} + ./release_obs.sh $target cp -f arch/arm/boot/zImage %_builddir/zImage.$target cp -f arch/arm/boot/dzImage %_builddir/dzImage.$target diff --git a/release_obs.sh b/release_obs.sh index 6e5b05b..3675592 100755 --- a/release_obs.sh +++ b/release_obs.sh @@ -12,8 +12,7 @@ CONFIG_STR=${INPUT_STR%_smk_dis*} #CONFIG_STR=${INPUT_STR%_tima_en*} OPTION_STR=${INPUT_STR#*${CONFIG_STR}} -INPUT_STR2=${2} -echo "defconfig : ${CONFIG_STR}_defconfig , option : ${OPTION_STR}, Release : ${INPUT_STR2}" +echo "defconfig : ${CONFIG_STR}_defconfig , option : ${OPTION_STR}" if [ "${OPTION_STR}" = "_smk_dis" ]; then echo "Now change smack-disable for ${CONFIG_STR}_defconfig" @@ -59,16 +58,6 @@ if [ "${OPTION_STR}" = "_tima_en" ]; then fi fi -if [ "${INPUT_STR2}" = "USR" ]; then - echo "Now disable CONFIG_SLP_KERNEL_ENG for ${CONFIG_STR}_defconfig" - - sed -i 's/CONFIG_SLP_KERNEL_ENG=y/\# CONFIG_SLP_KERNEL_ENG is not set/g' arch/arm/configs/${CONFIG_STR}_defconfig - if [ "$?" != "0" ]; then - echo "Failed to disable CONFIG_SLP_KERNEL_ENG feature" - exit 1 - fi -fi - make ARCH=arm ${CONFIG_STR}_defconfig if [ "$?" != "0" ]; then echo "Failed to make defconfig" -- 2.7.4 From 92a772b8dbd77e71514da37674fa3d86fdf59d75 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 31 Aug 2016 13:33:11 +0900 Subject: [PATCH 05/16] build: scripts: add input parameters to sprd_dtbtool.sh Instead of fixed dtb file list and its hw platform information, this patch adds input parameters to get proper dtb files and to consider reversed dtc hw platform information. Change-Id: I29b8da3c3520ac6619777d1b4e4456a32d28ba44 Signed-off-by: Seung-Woo Kim --- release.sh | 2 +- release_obs.sh | 2 +- scripts/sprd_dtbtool.sh | 173 +++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 145 insertions(+), 32 deletions(-) diff --git a/release.sh b/release.sh index b947192..e7d03c0 100755 --- a/release.sh +++ b/release.sh @@ -47,7 +47,7 @@ if [ "$?" != "0" ]; then exit 1 fi -./scripts/sprd_dtbtool.sh +./scripts/sprd_dtbtool.sh -p ${DTC_PATH} -v ${BOOT_PATH}/dts/ if [ "$?" != "0" ]; then echo "Failed to make merged-dtb" exit 1 diff --git a/release_obs.sh b/release_obs.sh index 3675592..e875862 100755 --- a/release_obs.sh +++ b/release_obs.sh @@ -80,7 +80,7 @@ if [ "$?" != "0" ]; then exit 1 fi -./scripts/sprd_dtbtool.sh +./scripts/sprd_dtbtool.sh -p ${DTC_PATH} -v ${BOOT_PATH}/dts/ if [ "$?" != "0" ]; then echo "Failed to make merged-dtb" exit 1 diff --git a/scripts/sprd_dtbtool.sh b/scripts/sprd_dtbtool.sh index 14a1f36..9f447ee 100755 --- a/scripts/sprd_dtbtool.sh +++ b/scripts/sprd_dtbtool.sh @@ -2,10 +2,11 @@ ## Functions -function write_to_4bytes_binary() +function write_hex_to_4bytes_binary() { - HEX=`echo "obase=16; $1" | bc` + HEX=$1 + HEX=${HEX#0x} NUM=$((8-${#HEX})) ZERO="00000000" @@ -19,6 +20,13 @@ function write_to_4bytes_binary() done > $2 } +function write_to_4bytes_binary() +{ + HEX=`echo "obase=16; $1" | bc` + + write_hex_to_4bytes_binary $HEX $2 +} + function write_to_padding_binary() { rm -f padding @@ -30,7 +38,9 @@ function write_to_padding_binary() touch padding fi - echo -en " | PAD: $PAD_SIZE[B]\n" + if [ "${VERBOSE}" -eq "1" ]; then + echo -en " | PAD: $PAD_SIZE[B]\n" + fi } function get_dtb_size() @@ -40,33 +50,122 @@ function get_dtb_size() DTB_SIZE=$(($SIZE + $PAD_SIZE)) } +function help() { + echo "sprd_dtbtool.sh [OPTIONS] -o " + echo " options:" + echo " --output-file/-o output file" + echo " --dtc-path/-p path to dtc" + echo " --page-size/-s page size in bytes" + echo " --verbose/-v verbose" + echo " --help/-h this help screen" + exit 0 +} + ## Defines OUT="merged-dtb" OUT_TMP="multi.tmp" OUT_DIR="./arch/arm/boot" -DTS_DIR="./arch/arm/boot/dts" +DTC_PATH=scripts/dtc SPRD_MAGIC="SPRD" SPRD_VERSION=1 - -DTB=( -"sprd-scx35-tizen_z3-r00.dtb" -"sprd-scx35-tizen_z3-r01.dtb" -"sprd-scx35-tizen_z3-r02.dtb" -"sprd-scx35-tizen_z3-r03.dtb" -) -DTB_CNT=4 - -CHIPSET=8830 -PLATFORM=0 -REV=131072 -DTB_OFFSET=2048 +SPRD_TAG="sprd,sc-id" ENDOFHEADER=0 +let MAX_PAD_SIZE=1024*1024 PAD=2048 +VERBOSE=0 + +if [ "$#" -eq "0" ]; then + help +fi + + +## Input parameters +params="$(getopt -o o:p:s:vh -l output-file:,dtc-path:,page-size:,verbose,help --name "$0" -- "$@")" +eval set -- "$params" +while true +do + case "$1" in + -o|--output-file) + OUTPUT_FILE=$2 + shift 2 + OUT_DIR=`dirname $OUTPUT_FILE` + if [ ! -d "$OUT_DIR" ]; then + echo "invalid output path '$OUT_DIR'." + exit 1 + fi + OUT=${OUTPUT_FILE#${OUT_DIR}} + OUT=${OUT//\//} + OUT_TMP=${OUT}.tmp + ;; + -p|--dtc-path) + DTC_PATH=$2 + shift 2 + ;; + -s|--page-size) + PAD=$2 + shift 2 + R=${PAD#-} + R=${R//[0-9]/} + # page size should be number, and larger than 0, and smaller than 1024*1024 + if [ ! -z "$R" ] || [ "$PAD" -lt "0" ] || [ "$PAD" -gt "$MAX_PAD_SIZE" ]; then + echo "invalid page size." + exit 1 + fi + ;; + -v|--verbose) + VERBOSE=1 + shift + ;; + -h|--help) + help + ;; + --) + shift + break + ;; + *) + help + ;; + esac +done + +if [ "$#" -eq "0" ]; then + help +fi + +DTS_DIR=$1 +DTS_DIR=${DTS_DIR%\/} +if [ ! -d "$DTS_DIR" ]; then + echo "invalid DTB input path '$DTS_DIR'." + exit 1 +else + DTB=(`find ${DTS_DIR} -name "*.dtb"`) + for i in ${DTB[*]}; do + if [ -e $i ]; then + TAG_CHECK=`${DTC_PATH}/dtc -I dtb -O dts $i 2>/dev/null | grep "${SPRD_TAG}"` + if [ "z${TAG_CHECK}" == "z" ]; then + # no tag in the dtb file + DTB=(${DTB[@]/$i}) + fi + fi + done +fi + +if [ ! -f "$DTC_PATH/dtc" ]; then + echo "no DTC file in '$DTC_PATH'." + exit 1 +fi + +if [ "${VERBOSE}" -eq "1" ]; then + echo "DTB input path is '${DTS_DIR}'" + echo "output path is '${OUT_DIR}', output file is '${OUT}'" + echo "page size is '${PAD}'" +fi ## Header @@ -74,10 +173,14 @@ rm -f $OUT rm -f $OUT_TMP touch $OUT_TMP +DTB_CNT=${#DTB[@]} HEADER_SIZE=$((12 + 20 * $DTB_CNT + 4)) +DTB_OFFSET=$PAD -echo -en " *HEADER " -echo -en "$HEADER_SIZE[B]\n" +if [ "${VERBOSE}" -eq "1" ]; then + echo -en " *HEADER " + echo -en "$HEADER_SIZE[B]\n" +fi echo -en $SPRD_MAGIC > $OUT cat $OUT >> $OUT_TMP @@ -87,16 +190,22 @@ write_to_4bytes_binary $DTB_CNT $OUT cat $OUT >> $OUT_TMP for i in ${DTB[*]}; do - FILE="$DTS_DIR/$i" + FILE="$i" if [ -e $FILE ]; then - write_to_4bytes_binary $CHIPSET $OUT + TAG_CHECK=`${DTC_PATH}/dtc -I dtb -O dts $i 2>/dev/null | grep "${SPRD_TAG}"` + TAG_CHECK=${TAG_CHECK#*<} + TAG_CHECK=${TAG_CHECK%>*} + CHIPSET=`echo ${TAG_CHECK} | awk '{ print $1 }'` + PLATFORM=`echo ${TAG_CHECK} | awk '{ print $2 }'` + REV=`echo ${TAG_CHECK} | awk '{ print $3 }'` + + write_hex_to_4bytes_binary $CHIPSET $OUT cat $OUT >> $OUT_TMP - write_to_4bytes_binary $PLATFORM $OUT + write_hex_to_4bytes_binary $PLATFORM $OUT cat $OUT >> $OUT_TMP - PLATFORM=$(($PLATFORM + 1)) - write_to_4bytes_binary $REV $OUT + write_hex_to_4bytes_binary $REV $OUT cat $OUT >> $OUT_TMP write_to_4bytes_binary $DTB_OFFSET $OUT @@ -122,15 +231,16 @@ cat $OUT_TMP padding > $OUT ## DTB for i in ${DTB[*]}; do - FILE="$DTS_DIR/$i" + FILE="$i" if [ -e $FILE ]; then NAME=`echo $i` - echo -en " *$NAME " + SIZE=`du -b $FILE | awk '{print $1}'` cat $OUT $FILE > $OUT_TMP - - SIZE=`du -b $FILE | awk '{print $1}'` - echo -en "$SIZE[B]\n" + if [ "${VERBOSE}" -eq "1" ]; then + echo -en " *$NAME " + echo -en "$SIZE[B]\n" + fi write_to_padding_binary $SIZE cat $OUT_TMP padding > $OUT @@ -149,4 +259,7 @@ mv -f $OUT $OUT_DIR/ S=`du -b $OUT_DIR/$OUT | awk '{print $1}'` S_K=$(($S/1024)) -echo -en "## OUT: $OUT size: $S[B]; $S_K[K]\n" +if [ "${VERBOSE}" -eq "1" ]; then + echo -en "## OUT: $OUT size: $S[B]; $S_K[KB]\n" +fi +echo "$OUT_DIR/$OUT (size: ${S_K}KB) is created." -- 2.7.4 From eb77b79a9c3c47b1dd82dfef6d8d72ae962bc7b5 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 31 Aug 2016 20:21:04 +0900 Subject: [PATCH 06/16] build: scripts: add input parameters to sprd_mkdzimage.sh Instead of fixed kernel and dtb files, this patch adds input parameters to get proper kernel and dtb files. Change-Id: Icd253cff63e7bccf12ddead4360417da05a7c7ef Signed-off-by: Seung-Woo Kim --- release.sh | 2 +- release_obs.sh | 2 +- scripts/sprd_mkdzimage.sh | 151 +++++++++++++++++++++++++++++++--------------- 3 files changed, 105 insertions(+), 50 deletions(-) diff --git a/release.sh b/release.sh index e7d03c0..2844293 100755 --- a/release.sh +++ b/release.sh @@ -53,7 +53,7 @@ if [ "$?" != "0" ]; then exit 1 fi -./scripts/sprd_mkdzimage.sh +./scripts/sprd_mkdzimage.sh -o ${BOOT_PATH}/${DZIMAGE} -k ${BOOT_PATH}/zImage -d ${BOOT_PATH}/merged-dtb if [ "$?" != "0" ]; then echo "Failed to make mkdzImage" exit 1 diff --git a/release_obs.sh b/release_obs.sh index e875862..8f475db 100755 --- a/release_obs.sh +++ b/release_obs.sh @@ -86,7 +86,7 @@ if [ "$?" != "0" ]; then exit 1 fi -./scripts/sprd_mkdzimage.sh +./scripts/sprd_mkdzimage.sh -o ${BOOT_PATH}/${DZIMAGE} -k ${BOOT_PATH}/zImage -d ${BOOT_PATH}/merged-dtb if [ "$?" != "0" ]; then echo "Failed to make mkdzImage" exit 1 diff --git a/scripts/sprd_mkdzimage.sh b/scripts/sprd_mkdzimage.sh index f6ea777..eb6f862 100755 --- a/scripts/sprd_mkdzimage.sh +++ b/scripts/sprd_mkdzimage.sh @@ -33,13 +33,21 @@ function write_to_padding_binary() echo -en " | PAD: $PAD_SIZE[B]\n" } +function help() { + echo "sprd_mkdzimage.sh [OPTIONS] -o -k " + echo " options:" + echo " --output-file/-o output file" + echo " --kernel/-k kernel file" + echo " --devicetree/-d devicetree file" + echo " --help/-h this help screen" + exit 0 +} + ## Defines OUT="dzImage" OUT_TMP="dzImage.tmp" - OUT_DIR="./arch/arm/boot" -BOOT_DIR="./arch/arm/boot" MAGIC="NZIT" # 0x54495A4E KERNEL_ADDR=32768 # 0x00008000 @@ -48,6 +56,65 @@ ATAGS_ADDR=31457280 # 0x01e00000 PAD=2048 +if [ "$#" -eq "0" ]; then + help +fi + + +## Input parameters +params="$(getopt -o o:k:d:h -l output-file:,:kernel:,devicetree:,help --name "$0" -- "$@")" +eval set -- "$params" +while true +do + case "$1" in + -o|--output-file) + OUTPUT_FILE=$2 + shift 2 + OUT_DIR=`dirname $OUTPUT_FILE` + if [ ! -d "$OUT_DIR" ]; then + echo "invalid output path '$OUT_DIR'." + exit 1 + fi + OUT=${OUTPUT_FILE#${OUT_DIR}} + OUT=${OUT//\//} + OUT_TMP=${OUT}.tmp + ;; + -k|--kernel) + KERNEL=$2 + shift 2 + ;; + -d|--devicetree) + DEVICETREE=$2 + shift 2 + ;; + -h|--help) + help + ;; + --) + shift + break + ;; + *) + help + ;; + esac +done + +if [ "z${KERNEL}" == "z" ] || [ "z${DEVICETREE}" == "z" ]; then + help +fi + +if [ ! -e "${KERNEL}" ]; then + echo -en "kernel '${KERNEL}' not found.\nexit\n" + exit -1 +fi + +if [ ! -e "${DEVICETREE}" ]; then + echo -en "devicetree '${DEVICETREE}' not found.\nexit\n" + exit -1 +fi + + ## Header rm -f $OUT rm -f $OUT_TMP @@ -63,29 +130,19 @@ cat $OUT >> $OUT_TMP write_to_4bytes_binary $KERNEL_ADDR $OUT cat $OUT >> $OUT_TMP -FILE="$BOOT_DIR/zImage" -if [ -e $FILE ]; then - SIZE=`du -b $FILE | awk '{print $1}'` - write_to_4bytes_binary $SIZE $OUT - cat $OUT >> $OUT_TMP -else - echo -en "$FILE not found.\nexit\n" - exit -1 -fi +FILE="${KERNEL}" +SIZE=`du -b $FILE | awk '{print $1}'` +write_to_4bytes_binary $SIZE $OUT +cat $OUT >> $OUT_TMP DTB_ADDR=$(($KERNEL_ADDR + $SIZE)) write_to_4bytes_binary $DTB_ADDR $OUT cat $OUT >> $OUT_TMP -FILE="$BOOT_DIR/merged-dtb" -if [ -e $FILE ]; then - SIZE=`du -b $FILE | awk '{print $1}'` - write_to_4bytes_binary $SIZE $OUT - cat $OUT >> $OUT_TMP -else - echo -en "$FILE not found.\nexit\n" - exit -1 -fi +FILE="${DEVICETREE}" +SIZE=`du -b $FILE | awk '{print $1}'` +write_to_4bytes_binary $SIZE $OUT +cat $OUT >> $OUT_TMP write_to_4bytes_binary $ATAGS_ADDR $OUT cat $OUT >> $OUT_TMP @@ -97,37 +154,35 @@ cat $OUT_TMP padding > $OUT ## Kernel Binary -FILE="$BOOT_DIR/zImage" -if [ -e $FILE ]; then - echo -en " *zImage " - cat $OUT $FILE > $OUT_TMP - - SIZE=`du -b $FILE | awk '{print $1}'` - echo -en "$SIZE[B]\n" - - write_to_padding_binary $SIZE - cat $OUT_TMP padding > $OUT -else - echo -en "zImage not found.\nexit\n" - exit -1 -fi +FILE="${KERNEL}" +FILE_PATH=`dirname ${KERNEL}` +FILE_NAME=${FILE#${FILE_PATH}} +FILE_NAME=${FILE_NAME//\//} +echo -en " *${FILE_NAME} " +cat $OUT $FILE > $OUT_TMP -## merged-dtb Binary -FILE="$BOOT_DIR/merged-dtb" -if [ -e $FILE ]; then - echo -en " *merged-dtb " - cat $OUT $FILE > $OUT_TMP +SIZE=`du -b $FILE | awk '{print $1}'` +echo -en "$SIZE[B]\n" - SIZE=`du -b $FILE | awk '{print $1}'` - echo -en "$SIZE[B]\n" +write_to_padding_binary $SIZE +cat $OUT_TMP padding > $OUT - write_to_padding_binary $SIZE - cat $OUT_TMP padding > $OUT -else - echo -en "merged-dtb not found.\nexit\n" - exit -1 -fi + +## Devicetree Binary +FILE="${DEVICETREE}" +FILE_PATH=`dirname ${DEVICETREE}` +FILE_NAME=${FILE#${FILE_PATH}} +FILE_NAME=${FILE_NAME//\//} + +echo -en " *${FILE_NAME} " +cat $OUT $FILE > $OUT_TMP + +SIZE=`du -b $FILE | awk '{print $1}'` +echo -en "$SIZE[B]\n" + +write_to_padding_binary $SIZE +cat $OUT_TMP padding > $OUT ## END @@ -138,4 +193,4 @@ mv -f $OUT $OUT_DIR/ S=`du -b $OUT_DIR/$OUT | awk '{print $1}'` S_K=$(($S/1024)) -echo -en "## OUT: $OUT size: $S[B]; $S_K[K]\n" +echo -en "## OUT: $OUT size: $S[B]; $S_K[KB]\n" -- 2.7.4 From d6e68cb0303d38fca82d33ef265e035cd9cfe442 Mon Sep 17 00:00:00 2001 From: jooseong lee Date: Fri, 2 Sep 2016 17:09:30 +0900 Subject: [PATCH 07/16] Smack: Fix wrong backporting for Smack Regard of: Smack: secmark support for netfilter (d587ffac0e6b0849334d575bca4e9e1caa48f891) Smack used to use a mix of smack_known struct and char* throughout its APIs and implementation. I confused it. It should be char*, not smack_known struct. (The latest kernel has a unified format, smack_known struct.) Change-Id: Ifd93e8b3d85c867c8d7a903470abc45e589a1a37 Signed-off-by: jooseong lee --- security/smack/smack_lsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index a7f2b5b..b72abc2 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -3751,8 +3751,8 @@ access_check: ad.a.u.net->netif = skb->skb_iif; ipv6_skb_to_auditdata(skb, &ad.a, NULL); #endif /* CONFIG_AUDIT */ - rc = smk_access(skp, ssp->smk_in, MAY_WRITE, &ad); - rc = smk_bu_note("IPv6 delivery", skp, ssp->smk_in, + rc = smk_access(skp, ssp->smk_in->smk_known, MAY_WRITE, &ad); + rc = smk_bu_note("IPv6 delivery", skp, ssp->smk_in->smk_known, MAY_WRITE, rc); #else /* CONFIG_SECURITY_SMACK_NETFILTER */ rc = smk_ipv6_port_check(sk, &sadd, SMK_RECEIVING); -- 2.7.4 From f500e7d1093f8a0f58bab4e185ccb0b5fd24c11c Mon Sep 17 00:00:00 2001 From: Krzysztof Opasiak Date: Thu, 1 Sep 2016 18:37:59 +0200 Subject: [PATCH 08/16] usb: gadget: Allow to build multiple legacy gadgets Currently it is possible to build in only one legac gadget *OR* compile multiple of them as a modules. It's not possible to mix those 2 ways of building them. This is limited only by Kconfig not any functionality. This patch removes this limitation. With this patch it is possible to set up all build combinations: 1) Multiple gadgets build in 2) Some gadgets build in and some build as a modules etc. As this patch makes Kconfig quite complicated let me clarify how it works: USB_F_ - used in makefile for compilation USB_G__REQ_F_ - set up by gadget to mark that this particular gadget requires this func to work USB_F__SELECTOR - helper config which is used to determine if function should be build in or compiled as a module Change-Id: I43b764ff27d08484df140835a6f2dee35d621248 Signed-off-by: Krzysztof Opasiak --- drivers/usb/gadget/Kconfig | 222 +++++++++++++++++++++++++++++++++------------ 1 file changed, 166 insertions(+), 56 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 55c7c57..16b3882 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -518,50 +518,167 @@ config USB_SPRD_SWITCH # composite based drivers config USB_LIBCOMPOSITE - tristate + tristate "USB Gadget Drivers" select CONFIGFS_FS depends on USB_GADGET config USB_F_ACM tristate +# Just a dummy config which indicates that serial gadget requires ACM in particular state +config USB_G_SERIAL_REQ_F_ACM + tristate + +# Just a dummy config which indicates that cdc gadget requires ACM in particular state +config USB_G_CDC_COMPOSITE_REQ_F_ACM + tristate + +# Just a dummy config which indicates that nokia gadget requires ACM in particular state +config USB_G_NOKIA_REQ_F_ACM + tristate + +# Just a dummy config which indicates that acm ms gadget requires ACM in particular state +config USB_G_ACM_MS_REQ_F_ACM + tristate + +# Just a dummy config which indicates that gadget multi requires ACM in particular state +config USB_G_MULTI_REQ_F_ACM + tristate + +# Just a dummy config which indicates that android gadget requires ACM in particular state +config USB_G_ANDROID_REQ_F_ACM + tristate + +# Just a dummy config which indicates that slp gadget requires ACM in particular state +config USB_G_SLP_REQ_F_ACM + tristate + +if USB_G_SERIAL_REQ_F_ACM = y || USB_G_CDC_COMPOSITE_REQ_F_ACM = y || USB_G_NOKIA_REQ_F_ACM = y || USB_G_ACM_MS_REQ_F_ACM = y || USB_G_MULTI_REQ_F_ACM = y || USB_G_ANDROID_REQ_F_ACM = y || USB_G_SLP_REQ_F_ACM = y + config USB_F_ACM_SELECTOR + tristate + default y + select USB_F_ACM + select USB_F_ACM_REQ_U_SERIAL + endif + + if !(USB_G_SERIAL_REQ_F_ACM = y || USB_G_CDC_COMPOSITE_REQ_F_ACM = y || USB_G_NOKIA_REQ_F_ACM = y || USB_G_ACM_MS_REQ_F_ACM = y || USB_G_MULTI_REQ_F_ACM = y || USB_G_SLP_REQ_F_ACM = y) && (USB_G_SERIAL_REQ_F_ACM = m || USB_G_CDC_COMPOSITE_REQ_F_ACM = m || USB_G_NOKIA_REQ_F_ACM = m || USB_G_ACM_MS_REQ_F_ACM = m || USB_G_MULTI_REQ_F_ACM = m || USB_G_ANDROID_REQ_F_ACM = m || USB_G_SLP_REQ_F_ACM = m) + config USB_F_ACM_SELECTOR + tristate + default m + select USB_F_ACM + select USB_F_ACM_REQ_U_SERIAL + endif + config USB_F_SS_LB tristate +# Just a dummy config which indicates that gadget zero requires SS and LB in particular state +config USB_G_ZERO_REQ_F_SS_LB + tristate + +if USB_G_ZERO_REQ_F_SS_LB = y +config USB_F_SS_LB_SELECTOR + tristate + default y + select USB_F_SS_LB +endif + +if !(USB_G_ZERO_REQ_F_SS_LB = y) && (USB_G_ZERO_REQ_F_SS_LB = m) +config USB_F_SS_LB_SELECTOR + tristate + default m + select USB_F_SS_LB +endif + config USB_U_SERIAL tristate +# Just a dummy config which indicates that F_ACM requires U_SERIAL in particular state +config USB_F_ACM_REQ_U_SERIAL + tristate + +# Just a dummy config which indicates that F_SERIAL requires U_SERIAL in particular state +config USB_F_SERIAL_REQ_U_SERIAL + tristate + +# Just a dummy config which indicates that F_OBEX requires U_SERIAL in particular state +config USB_F_OBEX_REQ_U_SERIAL + tristate + +# Just a dummy config which indicates that dbg gadget requires U_SERIAL in particular state +config USB_G_DBG_REQ_U_SERIAL + tristate + +if USB_F_ACM_REQ_U_SERIAL = y || USB_F_SERIAL_REQ_U_SERIAL = y || USB_F_OBEX_REQ_U_SERIAL = y || USB_G_DBG_REQ_U_SERIAL = y +config USB_U_SERIAL_SELECTOR + tristate + default y + select USB_U_SERIAL +endif + +if !(USB_F_ACM_REQ_U_SERIAL = y || USB_F_SERIAL_REQ_U_SERIAL = y || USB_F_OBEX_REQ_U_SERIAL = y || USB_G_DBG_REQ_U_SERIAL = y) && (USB_F_ACM_REQ_U_SERIAL = m || USB_F_SERIAL_REQ_U_SERIAL = m || USB_F_OBEX_REQ_U_SERIAL = m || USB_G_DBG_REQ_U_SERIAL = m) +config USB_U_SERIAL_SELECTOR + tristate + default m + select USB_U_SERIAL +endif + config USB_F_SERIAL tristate +# Just a dummy config which indicates that serial gadget requires SERIAL in particular state +config USB_G_SERIAL_REQ_F_SERIAL + tristate + +if USB_G_SERIAL_REQ_F_SERIAL = y +config USB_F_SERIAL_SELECTOR + tristate + default y + select USB_F_SERIAL + select USB_F_SERIAL_REQ_U_SERIAL +endif + +if !(USB_G_SERIAL_REQ_F_SERIAL = y) && (USB_G_SERIAL_REQ_F_SERIAL = m) +config USB_F_SERIAL_SELECTOR + tristate + default m + select USB_F_SERIAL + select USB_F_SERIAL_REQ_U_SERIAL +endif config USB_F_OBEX tristate -choice - tristate "USB Gadget Drivers" - default USB_ETH - help - A Linux "Gadget Driver" talks to the USB Peripheral Controller - driver through the abstract "gadget" API. Some other operating - systems call these "client" drivers, of which "class drivers" - are a subset (implementing a USB device class specification). - A gadget driver implements one or more USB functions using - the peripheral hardware. - - Gadget drivers are hardware-neutral, or "platform independent", - except that they sometimes must understand quirks or limitations - of the particular controllers they work with. For example, when - a controller doesn't support alternate configurations or provide - enough of the right types of endpoints, the gadget driver might - not be able work with that controller, or might need to implement - a less common variant of a device class protocol. +# Just a dummy config which indicates that serial gadget requires OBEX in particular state +config USB_G_SERIAL_REQ_F_OBEX + tristate +# Just a dummy config which indicates that nokia gadget requires OBEX in particular state +config USB_G_NOKIA_REQ_F_OBEX + tristate + +if USB_G_SERIAL_REQ_F_OBEX = y || USB_G_NOKIA_REQ_F_OBEX = y +config USB_F_OBEX_SELECTOR + tristate + default y + select USB_F_OBEX + select USB_F_OBEX_REQ_U_SERIAL +endif + +if !(USB_G_SERIAL_REQ_F_OBEX = y || USB_G_NOKIA_REQ_F_OBEX = y) && (USB_G_SERIAL_REQ_F_OBEX = m || USB_G_NOKIA_REQ_F_OBEX = m) +config USB_F_OBEX_SELECTOR + tristate + default m + select USB_F_OBEX + select USB_F_OBEX_REQ_U_SERIAL +endif + +menu "Legacy USB Gadget Drivers" # this first set of drivers all depend on bulk-capable hardware. config USB_ZERO tristate "Gadget Zero (DEVELOPMENT)" - select USB_LIBCOMPOSITE - select USB_F_SS_LB + depends on USB_LIBCOMPOSITE + select USB_G_ZERO_REQ_F_SS_LB help Gadget Zero is a two-configuration device. It either sinks and sources bulk data; or it loops back a configurable number of @@ -597,7 +714,7 @@ config USB_ZERO_HNPTEST config USB_AUDIO tristate "Audio Gadget" depends on SND - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE select SND_PCM help This Gadget Audio driver is compatible with USB Audio Class @@ -626,7 +743,7 @@ config GADGET_UAC1 config USB_ETH tristate "Ethernet Gadget (with CDC Ethernet support)" depends on NET - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE select CRC32 help This driver implements Ethernet style communication, in one of @@ -662,7 +779,7 @@ config USB_ETH config USB_ETH_RNDIS bool "RNDIS support" depends on USB_ETH - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE default y help Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol, @@ -681,7 +798,7 @@ config USB_ETH_RNDIS config USB_ETH_EEM bool "Ethernet Emulation Model (EEM) support" depends on USB_ETH - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE default n help CDC EEM is a newer USB standard that is somewhat simpler than CDC ECM @@ -698,7 +815,7 @@ config USB_ETH_EEM config USB_G_NCM tristate "Network Control Model (NCM) support" depends on NET - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE select CRC32 help This driver implements USB CDC NCM subclass standard. NCM is @@ -723,7 +840,7 @@ config USB_GADGETFS config USB_FUNCTIONFS tristate "Function Filesystem" - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE select USB_FUNCTIONFS_GENERIC if !(USB_FUNCTIONFS_ETH || USB_FUNCTIONFS_RNDIS) help The Function Filesystem (FunctionFS) lets one create USB @@ -762,7 +879,7 @@ config USB_FUNCTIONFS_GENERIC config USB_MASS_STORAGE tristate "Mass Storage Gadget" depends on BLOCK - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE help The Mass Storage Gadget acts as a USB Mass Storage disk drive. As its storage repository it can use a regular file or a block @@ -778,7 +895,7 @@ config USB_MASS_STORAGE config USB_GADGET_TARGET tristate "USB Gadget Target Fabric Module" depends on TARGET_CORE - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE help This fabric is an USB gadget. Two USB protocols are supported that is BBB or BOT (Bulk Only Transport) and UAS (USB Attached SCSI). BOT is @@ -789,11 +906,10 @@ config USB_GADGET_TARGET config USB_G_SERIAL tristate "Serial Gadget (with CDC ACM and CDC OBEX support)" depends on TTY - select USB_U_SERIAL - select USB_F_ACM - select USB_F_SERIAL - select USB_F_OBEX - select USB_LIBCOMPOSITE + select USB_G_SERIAL_REQ_F_ACM + select USB_G_SERIAL_REQ_F_SERIAL + select USB_G_SERIAL_REQ_F_OBEX + depends on USB_LIBCOMPOSITE help The Serial Gadget talks to the Linux-USB generic serial driver. This driver supports a CDC-ACM module option, which can be used @@ -814,7 +930,7 @@ config USB_G_SERIAL config USB_MIDI_GADGET tristate "MIDI Gadget" depends on SND - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE select SND_RAWMIDI help The MIDI Gadget acts as a USB Audio device, with one MIDI @@ -828,7 +944,7 @@ config USB_MIDI_GADGET config USB_G_PRINTER tristate "Printer Gadget" - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE help The Printer Gadget channels data between the USB host and a userspace program driving the print engine. The user space @@ -844,9 +960,8 @@ config USB_G_PRINTER config USB_G_ANDROID boolean "Android Composite Gadget" - select USB_F_ACM + select USB_G_ANDROID_REQ_F_ACM select USB_LIBCOMPOSITE - select USB_U_SERIAL help The Android Composite Gadget supports multiple USB functions: adb, acm, mass storage, mtp, accessory @@ -880,8 +995,7 @@ config USB_ANDROID_RNDIS_DWORD_ALIGNED config USB_G_SLP boolean "SLP Composite Gadget (similar to Android)" - select USB_F_ACM - select USB_U_SERIAL + select USB_G_SLP_REQ_F_ACM select USB_LIBCOMPOSITE help The SLP gadget driver supports multiple USB functions. @@ -895,9 +1009,8 @@ if TTY config USB_CDC_COMPOSITE tristate "CDC Composite Device (Ethernet and ACM)" depends on NET - select USB_LIBCOMPOSITE - select USB_U_SERIAL - select USB_F_ACM + depends on USB_LIBCOMPOSITE + select USB_G_CDC_COMPOSITE_REQ_F_ACM help This driver provides two functions in one configuration: a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link. @@ -912,9 +1025,8 @@ config USB_CDC_COMPOSITE config USB_G_NOKIA tristate "Nokia composite gadget" depends on PHONET - select USB_LIBCOMPOSITE - select USB_U_SERIAL - select USB_F_ACM + depends on USB_LIBCOMPOSITE + select USB_G_NOKIA_REQ_F_ACM help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver. @@ -925,9 +1037,8 @@ config USB_G_NOKIA config USB_G_ACM_MS tristate "CDC Composite Device (ACM and mass storage)" depends on BLOCK - select USB_LIBCOMPOSITE - select USB_U_SERIAL - select USB_F_ACM + depends on USB_LIBCOMPOSITE + select USB_G_ACM_MS_REQ_F_ACM help This driver provides two functions in one configuration: a mass storage, and a CDC ACM (serial port) link. @@ -939,9 +1050,8 @@ config USB_G_MULTI tristate "Multifunction Composite Gadget" depends on BLOCK && NET select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS - select USB_LIBCOMPOSITE - select USB_U_SERIAL - select USB_F_ACM + depends on USB_LIBCOMPOSITE + select USB_G_MULTI_REQ_F_ACM help The Multifunction Composite Gadget provides Ethernet (RNDIS and/or CDC Ethernet), mass storage and ACM serial link @@ -984,7 +1094,7 @@ endif # TTY config USB_G_HID tristate "HID Gadget" - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE help The HID gadget driver provides generic emulation of USB Human Interface Devices (HID). @@ -999,7 +1109,7 @@ config USB_G_HID config USB_G_DBGP tristate "EHCI Debug Device Gadget" depends on TTY - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE help This gadget emulates an EHCI Debug device. This is useful when you want to interact with an EHCI Debug Port. @@ -1032,7 +1142,7 @@ endif config USB_G_WEBCAM tristate "USB Webcam Gadget" depends on VIDEO_DEV - select USB_LIBCOMPOSITE + depends on USB_LIBCOMPOSITE select VIDEOBUF2_VMALLOC help The Webcam Gadget acts as a composite USB Audio and Video Class @@ -1042,7 +1152,7 @@ config USB_G_WEBCAM Say "y" to link the driver statically, or "m" to build a dynamically linked module called "g_webcam". -endchoice +endmenu config USB_CORE_IP_293A boolean "usb core ip version (synophsys)" -- 2.7.4 From 40fc7e74c62937f0c24b89ca4c9bc8099734d471 Mon Sep 17 00:00:00 2001 From: Krzysztof Opasiak Date: Thu, 1 Sep 2016 18:49:43 +0200 Subject: [PATCH 09/16] Update config for TM1 board due to changes in Kconfig Just a simple update due to changes in Kconfig of usb gadget subsystem. Change-Id: I21f96fd9ac826efe8bb056a67f0bba62643f13c8 Signed-off-by: Krzysztof Opasiak --- arch/arm/configs/tizen_tm1_defconfig | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm/configs/tizen_tm1_defconfig b/arch/arm/configs/tizen_tm1_defconfig index 86bc0ab..a656cde 100755 --- a/arch/arm/configs/tizen_tm1_defconfig +++ b/arch/arm/configs/tizen_tm1_defconfig @@ -2534,6 +2534,15 @@ CONFIG_USB_SPRD_DWC=y # CONFIG_USB_SPRD_SWITCH is not set CONFIG_USB_LIBCOMPOSITE=y CONFIG_USB_F_ACM=y +CONFIG_USB_G_SLP_REQ_F_ACM=y +CONFIG_USB_F_ACM_SELECTOR=y +CONFIG_USB_U_SERIAL=y +CONFIG_USB_F_ACM_REQ_U_SERIAL=y +CONFIG_USB_U_SERIAL_SELECTOR=y + +# +# Legacy USB Gadget Drivers +# CONFIG_USB_HOST_NOTIFY=y CONFIG_USB_NOTIFY_LAYER=y CONFIG_USB_NOTIFIER=y @@ -2550,7 +2559,6 @@ CONFIG_USB_EXTERNAL_DETECT=y # CONFIG_USB_G_PRINTER is not set # CONFIG_USB_G_ANDROID is not set CONFIG_USB_G_SLP=y -CONFIG_USB_DUN_SUPPORT=y # CONFIG_USB_CDC_COMPOSITE is not set # CONFIG_USB_G_ACM_MS is not set # CONFIG_USB_G_MULTI is not set @@ -2561,6 +2569,7 @@ CONFIG_USB_CORE_IP_293A=y # CONFIG_SPRD_USB_DEVICE_ONLY is not set # CONFIG_SHARK_PAD_HW_V102 is not set # CONFIG_USB_INTERRUPT_BY_MUIC is not set +CONFIG_USB_DUN_SUPPORT=y CONFIG_MMC=y # CONFIG_MMC_DEBUG is not set CONFIG_MMC_UNSAFE_RESUME=y -- 2.7.4 From 42136c50c98e4d374f56a5d4fb772f5e1198c53a Mon Sep 17 00:00:00 2001 From: Krzysztof Opasiak Date: Fri, 2 Sep 2016 12:52:40 +0200 Subject: [PATCH 10/16] Build dummy_hcd and g_ffs as a modules Change-Id: Ic505dd282eaf2740848fddbb98678d8fb147be1e Signed-off-by: Krzysztof Opasiak --- arch/arm/configs/tizen_tm1_defconfig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm/configs/tizen_tm1_defconfig b/arch/arm/configs/tizen_tm1_defconfig index a656cde..2498a75 100755 --- a/arch/arm/configs/tizen_tm1_defconfig +++ b/arch/arm/configs/tizen_tm1_defconfig @@ -2528,7 +2528,7 @@ CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2 # CONFIG_USB_MV_U3D is not set # CONFIG_USB_M66592 is not set # CONFIG_USB_NET2272 is not set -# CONFIG_USB_DUMMY_HCD is not set +CONFIG_USB_DUMMY_HCD=m CONFIG_USB_GADGET_SPRD_DWC=y CONFIG_USB_SPRD_DWC=y # CONFIG_USB_SPRD_SWITCH is not set @@ -2552,7 +2552,10 @@ CONFIG_USB_EXTERNAL_DETECT=y # CONFIG_USB_ETH is not set # CONFIG_USB_G_NCM is not set # CONFIG_USB_GADGETFS is not set -# CONFIG_USB_FUNCTIONFS is not set +CONFIG_USB_FUNCTIONFS=m +# CONFIG_USB_FUNCTIONFS_ETH is not set +# CONFIG_USB_FUNCTIONFS_RNDIS is not set +CONFIG_USB_FUNCTIONFS_GENERIC=y # CONFIG_USB_MASS_STORAGE is not set # CONFIG_USB_G_SERIAL is not set # CONFIG_USB_MIDI_GADGET is not set -- 2.7.4 From 4d0695a9e94f1e5979b4f56026ca589846b9afe0 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Mon, 5 Sep 2016 10:52:21 +0900 Subject: [PATCH 11/16] usb: gadget: f_fs: remove build warnings from ffs_epfile_io This patch removes build warnings to convert unsigned int pointer to char pointer from ffs_epfile_io(). Change-Id: I2b46093add10c647f3488220b123e3920a1cfeb4 Signed-off-by: Seung-Woo Kim --- drivers/usb/gadget/f_fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 1b35dea..250fc8a 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -772,9 +772,9 @@ static ssize_t ffs_epfile_io(struct file *file, int halt; if(read) - data = &recv_buffer[8]; + data = (char *)&recv_buffer[8]; else - data = &send_buffer[8]; + data = (char *)&send_buffer[8]; goto first_try; do { spin_unlock_irq(&epfile->ffs->eps_lock); -- 2.7.4 From 5064dad740bb7e17d810f55df540e837fff99969 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 7 Sep 2016 14:53:43 +0900 Subject: [PATCH 12/16] Input: ist30xxc: remove touch event log This patch removes touch event log. Change-Id: I4a3ec5ccaf8455a48a8f67769c2056162a97c4de Signed-off-by: Seung-Woo Kim Signed-off-by: Andi Shyti --- drivers/input/touchscreen/imagis_30xxc/ist30xxc.c | 50 ++--------------------- 1 file changed, 3 insertions(+), 47 deletions(-) diff --git a/drivers/input/touchscreen/imagis_30xxc/ist30xxc.c b/drivers/input/touchscreen/imagis_30xxc/ist30xxc.c index 09c93fa..4aa0fff 100644 --- a/drivers/input/touchscreen/imagis_30xxc/ist30xxc.c +++ b/drivers/input/touchscreen/imagis_30xxc/ist30xxc.c @@ -402,19 +402,7 @@ void print_tsp_event(struct ist30xx_data *data, finger_info *finger) /* touch down */ data->touch_pressed_num++; data->press_finger_cnt++; - tsp_noti("P [%d] x=%d y=%d z=%d\n", - idx, - finger->bit_field.x, - finger->bit_field.y, - finger->bit_field.area); data->tsp_touched[idx] = true; - } else { - /* touch move */ - tsp_debug("M [%d] x=%d y=%d z=%d\n", - idx, - finger->bit_field.x, - finger->bit_field.y, - finger->bit_field.area); } data->lx[idx] = finger->bit_field.x; @@ -427,13 +415,6 @@ void print_tsp_event(struct ist30xx_data *data, finger_info *finger) #ifdef CONFIG_SLEEP_MONITOR data->release_cnt++; #endif - tsp_noti("R [%d] x=%d y=%d z=%d c=%d v=0x%04x\n", - idx, - data->lx[idx], - data->ly[idx], - finger->bit_field.area, - data->press_cnt[idx], - data->fw.cur.fw_ver); data->tsp_touched[idx] = false; data->press_cnt[idx] = 0; if(data->press_finger_cnt > 0) @@ -452,17 +433,13 @@ void print_tkey_event(struct ist30xx_data *data, int id) bool press = PRESSED_KEY(data->t_status, id); if (press) { - if (tkey_pressed[idx] == false) { + if (tkey_pressed[idx] == false) /* tkey down */ - tsp_noti("k %s%d\n", TOUCH_DOWN_MESSAGE, id); tkey_pressed[idx] = true; - } } else { - if (tkey_pressed[idx] == true) { + if (tkey_pressed[idx] == true) /* tkey up */ - tsp_noti("k %s%d\n", TOUCH_UP_MESSAGE, id); tkey_pressed[idx] = false; - } } } #endif @@ -673,13 +650,9 @@ static irqreturn_t ist30xx_irq_thread(int irq, void *ptr) ms = get_milli_second(); if (intr_debug_addr >= 0 && intr_debug_size > 0) { - tsp_noti("Intr_debug (addr: 0x%08x)\n", intr_debug_addr); ist30xx_burst_read(data->client, IST30XX_DA_ADDR(intr_debug_addr), &msg[0], intr_debug_size, true); - for (i = 0; i < intr_debug_size; i++) - tsp_noti("\t%08x\n", msg[i]); - tracking_intr_debug_value = TRACKING_INTR_DEBUG1_VALID; ist30xx_put_track_ms(ms); ist30xx_put_track(&tracking_intr_debug_value, 1); @@ -687,13 +660,9 @@ static irqreturn_t ist30xx_irq_thread(int irq, void *ptr) } if (intr_debug2_addr >= 0 && intr_debug2_size > 0) { - tsp_noti("Intr_debug2 (addr: 0x%08x)\n", intr_debug2_addr); ist30xx_burst_read(data->client, IST30XX_DA_ADDR(intr_debug2_addr), &msg[0], intr_debug2_size, true); - for (i = 0; i < intr_debug2_size; i++) - tsp_noti("\t%08x\n", msg[i]); - tracking_intr_debug_value = TRACKING_INTR_DEBUG2_VALID; ist30xx_put_track_ms(ms); ist30xx_put_track(&tracking_intr_debug_value, 1); @@ -707,8 +676,6 @@ static irqreturn_t ist30xx_irq_thread(int irq, void *ptr) if (unlikely(ret)) goto irq_err; - tsp_verb("intr msg: 0x%08x\n", *msg); - /* TSP IC Exception */ if (unlikely((*msg & IST30XX_EXCEPT_MASK) == IST30XX_EXCEPT_VALUE)) { tsp_err("Occured IC exception(0x%02X)\n", *msg & 0xFF); @@ -826,15 +793,8 @@ static irqreturn_t ist30xx_irq_thread(int irq, void *ptr) data->z_values, finger_cnt, true); } - if (data->track_enable) { - + if (data->track_enable) ist30xx_put_track(msg + offset, finger_cnt); - for (i = 0; i < finger_cnt; i++) { - tsp_verb("intr msg(%d): 0x%08x, %d\n", - i + offset, msg[i + offset], data->z_values[i]); - } - - } } read_cnt = finger_cnt + 1; @@ -859,13 +819,9 @@ static irqreturn_t ist30xx_irq_thread(int irq, void *ptr) if (data->track_enable) { if (intr_debug3_addr >= 0 && intr_debug3_size > 0) { - tsp_noti("Intr_debug3 (addr: 0x%08x)\n", intr_debug3_addr); ist30xx_burst_read(data->client, IST30XX_DA_ADDR(intr_debug3_addr), &msg[0], intr_debug3_size, true); - for (i = 0; i < intr_debug3_size; i++) - tsp_noti("\t%08x\n", msg[i]); - tracking_intr_debug_value = TRACKING_INTR_DEBUG3_VALID; ist30xx_put_track_ms(ms); ist30xx_put_track(&tracking_intr_debug_value, 1); -- 2.7.4 From 21312b8e2fc715ceb13e216bd83e63ec646dce15 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 7 Sep 2016 14:56:10 +0900 Subject: [PATCH 13/16] Input: sprd_eic_keys: remove event log This patch removes event log. Change-Id: Iaeeaab3c71d3513edd3af51df5dbb870099fecd2 Signed-off-by: Seung-Woo Kim Signed-off-by: Andi Shyti --- drivers/input/keyboard/sprd_eic_keys.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/input/keyboard/sprd_eic_keys.c b/drivers/input/keyboard/sprd_eic_keys.c index 56f33ff..077d254 100644 --- a/drivers/input/keyboard/sprd_eic_keys.c +++ b/drivers/input/keyboard/sprd_eic_keys.c @@ -101,7 +101,6 @@ static irqreturn_t sprd_eic_irq_handle(int irq, void *dev_id) #endif input_report_key(this_pdata->input_dev, button->code, button_state_current); input_sync(this_pdata->input_dev); - PRINT_INFO("[P] %s\n", button->desc); if(1 == button->active_low) irq_set_irq_type(button->irq, IRQF_TRIGGER_HIGH); @@ -117,7 +116,6 @@ static irqreturn_t sprd_eic_irq_handle(int irq, void *dev_id) #endif input_report_key(this_pdata->input_dev, button->code, button_state_current); input_sync(this_pdata->input_dev); - PRINT_INFO("[R] %s\n", button->desc); if(1 == button->active_low) irq_set_irq_type(button->irq, IRQF_TRIGGER_LOW); -- 2.7.4 From 84a320692118483a871d97e90b9292e3f0b18bc4 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 7 Sep 2016 15:07:44 +0900 Subject: [PATCH 14/16] Input: sc_keypad: remove event log This patch removes key event log. Change-Id: I3cbe04efcd4e16b30616c59f96a30cafa72b6827 Signed-off-by: Seung-Woo Kim Signed-off-by: Andi Shyti --- drivers/input/keyboard/sc_keypad.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/drivers/input/keyboard/sc_keypad.c b/drivers/input/keyboard/sc_keypad.c index 8fdd948..2b5876d 100644 --- a/drivers/input/keyboard/sc_keypad.c +++ b/drivers/input/keyboard/sc_keypad.c @@ -221,8 +221,6 @@ static ssize_t key_show(struct device *dev, struct device_attribute *attr, char else is_key_checked = sprintf(buf, "%s\n", "RELEASE"); - printk("[KEY] Keyshort Press Check ==> keys_pressed : %x\n", keys_pressed); - return is_key_checked; } static ssize_t powerkey_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -233,9 +231,6 @@ static ssize_t powerkey_show(struct device *dev, struct device_attribute *attr, is_key_checked = sprintf(buf, "%s\n", sci_kpd->powerkey_state ? "PRESS" : "RELEASE"); - printk("[KEY] Keyshort Press Check ==> powerKeys_pressed : %ld \n", - sci_kpd->powerkey_state); - return is_key_checked; } @@ -310,25 +305,6 @@ static void dump_keypad_register(void) } #endif -static void sci_keypad_keydbg(unsigned short key, unsigned short state) -{ - const char* key_name[] = {"KEY_VOLUMEUP", "KEY_VOLUMEDOWN",\ - "KEY_HOME", "KEY_POWER", "UNKNOWN"}; - - if (key == KEY_VOLUMEUP) - key = 0; - else if (key == KEY_VOLUMEDOWN) - key = 1; - else if (key == KEY_MENU) - key = 2; - else if (key == KEY_POWER) - key = 3; - else - key = 4; - - printk("%s: [%s] %s\n", __func__, state ? "P":"R", key_name[key]); -} - static int sci_keypad_check_validity(unsigned short key) { if ((key == KEY_VOLUMEUP) || (key == KEY_VOLUMEDOWN) ||\ @@ -356,7 +332,6 @@ static void sci_keypad_report_event(struct sci_keypad_t *sci_kpd, int col, int r input_report_key(sci_kpd->input_dev, key, state); input_sync(sci_kpd->input_dev); sec_debug_check_crash_key(key, state); - sci_keypad_keydbg(key, state); return; } @@ -443,7 +418,6 @@ static irqreturn_t sci_powerkey_isr(int irq, void *dev_id) /* seems an event is missing, just report it */ input_report_key(sci_kpd->input_dev, key, last_value); input_sync(sci_kpd->input_dev); - sci_keypad_keydbg(key, !value); } if (value) { @@ -470,7 +444,6 @@ static irqreturn_t sci_powerkey_isr(int irq, void *dev_id) sec_debug_check_crash_key(key, value); #endif last_value = value; - sci_keypad_keydbg(key, !value); return IRQ_HANDLED; } -- 2.7.4 From f61f53eef2852f35ca9feaaec65a4a8c8ed256ee Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 7 Sep 2016 15:12:48 +0900 Subject: [PATCH 15/16] Input: tc305k: remove event log This patch removes key event log. Change-Id: I86f1967e54be571ab41d6025a1443e3aa2a25fda Signed-off-by: Seung-Woo Kim Signed-off-by: Andi Shyti --- drivers/input/keyboard/coreriver/tc350-touchkey.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/input/keyboard/coreriver/tc350-touchkey.c b/drivers/input/keyboard/coreriver/tc350-touchkey.c index 0d980a7..e834381 100644 --- a/drivers/input/keyboard/coreriver/tc350-touchkey.c +++ b/drivers/input/keyboard/coreriver/tc350-touchkey.c @@ -1954,8 +1954,6 @@ static irqreturn_t tc300k_interrupt(int irq, void *dev_id) goto out; } - dev_dbg(&client->dev, "%s: key_value=[0x%x]\n", __func__, key_val); - for (i = 0 ; i < data->num_key*2; i++) { if ((key_val & data->tsk_ev_val[i].tsk_bitmap)) { input_report_key(data->input_dev, @@ -1964,10 +1962,6 @@ static irqreturn_t tc300k_interrupt(int irq, void *dev_id) if (!data->tsk_ev_val[i].tsk_status) data->release_cnt++; - - dev_info(&client->dev, "%s:[%s] %s\n", __func__, - data->tsk_ev_val[i].tsk_status? "P" : "R", - data->tsk_ev_val[i].tsk_keyname); } } input_sync(data->input_dev); -- 2.7.4 From f510d3e4ccd7dcb769d11e34f4d0cf0474bbcffc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Szewczyk?= Date: Wed, 7 Sep 2016 21:24:12 +0200 Subject: [PATCH 16/16] usb: gadget: f_fs: add poll for endpoint 0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch adds poll function for file representing ep0. Ability of read from or write to ep0 file is related with actual state of ffs: - When desctiptors or strings are not written yet, POLLOUT flag is set. - If there is any event to read, POLLIN flag is set. - If setup request was read, POLLIN and POLLOUT flag is set, to allow send response (by performing I/O operation consistent with setup request direction) or set stall (by performing I/O operation opposite setup request direction). Signed-off-by: Robert Baldyga Acked-by: Michal Nazarewicz Signed-off-by: Felipe Balbi [Backported from mainline commit 23de91e] Signed-off-by: Paweł Szewczyk Signed-off-by: Krzysztof Opasiak Change-Id: I4286847252357b4796cc3794ce71d5a4ec2af9f5 --- drivers/usb/gadget/f_fs.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 250fc8a..ac03922 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -27,6 +27,8 @@ #include #include +#include + #define FUNCTIONFS_MAGIC 0xa647361 /* Chosen by a honest dice roll ;) */ @@ -736,6 +738,47 @@ static long ffs_ep0_ioctl(struct file *file, unsigned code, unsigned long value) return ret; } +static unsigned int ffs_ep0_poll(struct file *file, poll_table *wait) +{ + struct ffs_data *ffs = file->private_data; + unsigned int mask = POLLWRNORM; + int ret; + + poll_wait(file, &ffs->ev.waitq, wait); + + ret = ffs_mutex_lock(&ffs->mutex, file->f_flags & O_NONBLOCK); + if (unlikely(ret < 0)) + return mask; + + switch (ffs->state) { + case FFS_READ_DESCRIPTORS: + case FFS_READ_STRINGS: + mask |= POLLOUT; + break; + + case FFS_ACTIVE: + switch (ffs->setup_state) { + case FFS_NO_SETUP: + if (ffs->ev.count) + mask |= POLLIN; + break; + + case FFS_SETUP_PENDING: + case FFS_SETUP_CANCELED: + mask |= (POLLIN | POLLOUT); + break; + } + case FFS_CLOSING: + break; + case FFS_DEACTIVATED: + break; + } + + mutex_unlock(&ffs->mutex); + + return mask; +} + static const struct file_operations ffs_ep0_operations = { .llseek = no_llseek, @@ -744,6 +787,7 @@ static const struct file_operations ffs_ep0_operations = { .read = ffs_ep0_read, .release = ffs_ep0_release, .unlocked_ioctl = ffs_ep0_ioctl, + .poll = ffs_ep0_poll, }; -- 2.7.4